pixel0815
Goto Top

Kann mir mal sagen warum das Skript nicht mehr funktioniert?

Moin,

folgendes Skript hat mal einen brauchbaren CSV Output gebracht.
Jetzt erhalte ich nur noch die Meldung.
Was ist da los? face-sad

Ausnahme beim Aufrufen von "GetStringValue": "Der Parameter ist ungültig. "  
In C:\Identifziere_IE_Version_LDAP.ps1:21 Zeichen:5
+     $iePath = ($regProv.GetStringValue($HKLM, $IESubKeyName, "")).sValue  
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) , MethodInvocationException
    + FullyQualifiedErrorId : WMIMethodException

Skript ist das hier

          
  function Get-IEVersion {            
    param(            
      [String] $computerName            
    )            
    # Create custom object.            
    $outputObject = "" | Select-Object `  
      @{Name="ComputerName"; Expression={$computerName}},              
      @{Name="Path"; Expression={}},              
      @{Name="Version"; Expression={}},              
      @{Name="Error"; Expression={}}              
    # Step 1: Read App Paths subkey to get path of iexplore.exe.            
    try {            
      $regProv = [WMIClass] "\\$computerName\root\default:StdRegProv"              
    }            
    catch [System.Management.Automation.RuntimeException] {            
      # Update custom object with error message and return it.            
      $outputObject.Error = $_.Exception.InnerException.InnerException.Message            
      return $outputObject            
    }            
    $iePath = ($regProv.GetStringValue($HKLM, $IESubKeyName, "")).sValue              
    if ( -not $iePath ) {            
      # Update custom object with error message and return it.            
      return $outputObject            
    }            
    $outputObject.Path = $iePath            
    # Replace '\' with '\\' when specifying CIM_DataFile key path.              
    $iePath = $iePath -replace '\\', '\\'              
    # Step 2: Get the CIM_DataFile instance of iexplore.exe.            
    try {            
      $dataFile = [WMI] "\\$computerName\root\CIMV2:CIM_DataFile.Name='$iePath'"              
      # Update custom object with IE file version.            
      $outputObject.Version = $dataFile.Version            
    }            
    catch [System.Management.Automation.RuntimeException] {            
      # Update custom object with error message.            
      $outputObject.Error = $_.Exception.InnerException.InnerException.Message            
    }            
    # Return the custom object.            
    return $outputObject            
  }            

$computers= Get-ADComputer -Filter "Name -like 'server*'" -Properties * | Where-Object OperatingSystem -Like '*server*' | Select-Object -expandProperty Name  
#$computers= Get-ADComputer -Filter "Name -like '*'" -Properties * | Where-Object OperatingSystem -Like '*Server*' | Select-Object -expandProperty Name  
$temp = $null

foreach ( $computer in $Computers ) {            
    #Get-IEVersion $computer
    $temp +=,(Get-IEVersion $computer)

    } 

$temp | Out-GridView
$path = $temp | Export-Csv -Delimiter ';' -NoTypeInformation -Force -Path "W:\IEVersionen1.csv"  

Content-Key: 306405

Url: https://administrator.de/contentid/306405

Printed on: April 26, 2024 at 12:04 o'clock

Mitglied: 129413
Solution 129413 Jun 07, 2016 updated at 11:11:12 (UTC)
Goto Top
Weil die Variablen
$HKLM
und
$IESubKeyName
in der Zeile:
$regProv.GetStringValue($HKLM, $IESubKeyName, "")

nirgendwo definiert sind :-P Da hat einer was vergessen...Copy n'paste ist wohl doch nicht immer die beste Wahl face-wink
https://msdn.microsoft.com/de-de/library/aa390788%28v=vs.85%29.aspx
https://gallery.technet.microsoft.com/scriptcenter/Servers-Inventory-rep ...

Gruß skybird
Member: pixel0815
pixel0815 Jun 07, 2016 at 11:10:37 (UTC)
Goto Top
Hmm.. na super face-sad Da hat wohl jemand in der zwischenzeit rumgespielt und gespeichert.
Mitglied: 129413
129413 Jun 07, 2016 at 11:11:22 (UTC)
Goto Top
Member: pixel0815
pixel0815 Jun 07, 2016 at 11:42:47 (UTC)
Goto Top
  $HKLM = [UInt32] "0x80000002"  
  $IESubKeyName = "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\IEXPLORE.EXE"  

Damit läuft das allerdings zeigt der mir bei Windows 2008 R2 mit IE 11 an das dort eiin 8.0xxxx installiert sei? Mhmm..
Member: emeriks
emeriks Jun 07, 2016 at 11:48:42 (UTC)
Goto Top
Hi,
Hmm.. na super face-sad Da hat wohl jemand in der zwischenzeit rumgespielt und gespeichert.
Dagegen hilft Code Signierung!

E.
Member: pixel0815
pixel0815 Jun 07, 2016 at 11:50:25 (UTC)
Goto Top
OH fehler meinerseits.
Jetzt läuft alles. Da war tatsächlich ein 8er drauf.
Alles korrekt.
Vielen Dank :O)