Error result of IE version PS script RRS feed

  • Question

  • Hi,

    I found this PS script online:

    Function IEVersion {
    $Prop = [ordered]@{}
    $ComputerName = Cat C:\Nahal\Computers.txt
    $ErrorActionPreference = "Stop"  
    foreach ($computer in $ComputerName)  
    Try {
    $Syntax = GWMI win32_operatingsystem -cn $computer
    $Prop.Computername = $Syntax.CSName  
    $Prop.OperatingSystem = $Syntax.Caption  
    $Prop.ServicePack = $Syntax.CSDVersion  
    $Reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $computer)  
    $RegKey= $Reg.OpenSubKey("SOFTWARE\\Microsoft\\Internet Explorer")  
    $Prop.IEVersion = $Regkey.GetValue("Version")
    New-Object PSObject -property $Prop  
      Add-Content "$computer is not reachable" -path $env:USERPROFILE\Desktop\UnreachableHosts.txt
    #HTML Color Code
    $a = "<!--mce:0-->"
    IEVersion | ConvertTo-HTML -head $a -body "<H2> IE Version</H2>" |  
    Out-File $env:USERPROFILE\Desktop\DomainController.htm #HTML Output
    Invoke-Item $env:USERPROFILE\Desktop\DomainController.htm

    but I am getting this error:

    Unable to find type [ordered]: make sure that the assembly containing this type is loaded.

    At line:2 char:18

    + $Prop = [ordered] <<<< @{}

        + CategoryInfo          : InvalidOperation: (ordered:String) [], RuntimeException

        + FullyQualifiedErrorId : TypeNotFound

    Can you please help me to find what is going wrong?

    I tried this PS in another environment and it worked fine.

    Thank you so much,

    Friday, January 22, 2016 1:40 PM


All replies