ServerAssesment.ps1 (zpäť na zoznam) Skript zisťuje niekoľko nastavení, verzie firmvérov a ovládačov hardvérových komponentov.
			$ErrorActionPreference= 'silentlycontinue'

$systemInfoNDM = gwmi Win32_ComputerSystem #info for hostname, domain, model name
$model = $systemInfoNDM.Model + ";" #VM - VMware Virtual Platform; Hyper-V - Virtual Machine
if ($model -eq "VMware Virtual Platform;") {
    $model = "VMware;"
}
if ($model -eq "Virtual Machine;") {
    $model = "Hyper-V;"
}

$computerName=$systemInfoNDM.name + ";"
$systemInfoOS = gwmi Win32_OperatingSystem #info for Service pack, architecture
$OSVersion = $systemInfoOS.Caption + ";" #OS version name in format Microsoft Windows 7 Enteprise
$OSarchitecture = $systemInfoOS.OSArchitecture + ";" #architecture in format 32-bit, 64-bit
$servicePack = [string]$systemInfoOS.ServicePackMajorVersion + ";" #servicepack version

$cluster = get-service | Where-object {$_.name -eq "ClusSvc"} #check if server is part of cluster or not
if ($cluster.name -match "ClusSvc") {
    $isCluster = "YES;"
}
else {
    $isCluster = "NO;"
}


#initializing variables
$serialNumber = "N/A;"
$biosVersion = "N/A;"
$smartArrayFW = "N/A;"
$smartArrayDrvVersion = "N/A;"
$HBADriverVersion = "N/A;"
$HBAfirmware = "N/A;"
$HBABiosVersion = "N/A;"
$nicFWversion = "N/A;"
$NICDrvVersion = "N/A;"
$smhVersion = "N/A;"
$iloVersion = "N/A;"
$sppVersion = "N/A;"
$MPIODrvVersion = "N/A;"


#######check for drivers and firmware versions

if ($model -match "proliant") { #block for physical servers
    #info from BIOS: version, serialnumber
    $biosInfo = gwmi win32_bios
    $serialNumber = $biosInfo.SerialNumber + ";"
    $date = ($biosInfo.ReleaseDate).substring(6,2) + "/" + ($biosInfo.ReleaseDate).substring(4,2) + "/" + ($biosInfo.ReleaseDate).substring(0,4)
    $biosVersion = $biosInfo.SMBIOSBIOSVersion + " " + $date + ";"
    
    #check for WBEM providers, if there are not, namespace is not available, not able to check
    $wbem = gwmi win32_Product | WHere {$_.name -match "Wbem"}
    if ($wbem) {
    
        #Smart Array Firmware
        $smartArray = gwmi -class "HPSA_Firmware" -namespace "root\HPQ"
        if ($smartArray) { #check if object exists
            $smartArrayFW = $smartArray.VersionString + ";"
        }
        else {
            $smartArrayFW = "no version;"
        }
        
        #Smart Array Driver
        $smartArrayDrv = gwmi Win32_PnPSignedDriver | Where {$_.description -match 'smart array'}
        if ($smartArrayDrv) {
            $smartArrayDrvVersion = $smartArrayDrv.DriverVersion + ";"
        }
        else {
            $smartArrayDrvVersion = "no version;"
        }
        
        #HBA Driver
        $HBADriver = gwmi -class "HPFCHBA_SoftwareIdentityDrv" -namespace "root\HPQ"
        if ($HBADriver) {
            if ($HBADriver -is [system.array]) { #WMI could return object as array
                $HBADriverVersion = $HBADriver[0].VersionString + ";"
            }
            else {
                $HBADriverVersion = $HBADriver.VersionString
                if ($HBADriverVersion -isnot [system.array]) { #check if there are more than one result, if it is, variable becomes an array of objects and needs to be processed accordingly
                    $HBADriverVersion = $HBADriverVersion + ";"
                }
                else {
                    $HBADriverVersion = $HBADriverVersion[0] + ";"
                }
            }
        }
        else {
            $HBADriverVersion = "no version;"
        }
        
        #HBA Firmware
        $HBAfw = gwmi -class "HPFCHBA_FirmwareIdentityFW" -namespace "root\HPQ"
        if ($HBAfw) {
            if ($HBAfw -is [system.array]) { #WMI could return object as array
                $HBAfirmware = $HBAfw[0].VersionString + ";"
            }
            else {
                $HBAfirmware = $HBAfw.VersionString
                if ($HBAfirmware -isnot [system.array]) { #check if there are more than one result, if it is, variable becomes an array of objects and needs to be processed accordingly
                    $HBAfirmware = $HBAfirmware + ";"
                }
                else {
                    $HBAfirmware = $HBAfirmware[0] + ";"
                }
            }
        }
        else {
            $HBAfirmware = "no version;"
        }
        
        #HBA BIOS
        $HBABios = gwmi -class "HPFCHBA_FirmwareIdentityBIOS" -namespace "root\HPQ"
        if ($HBABios) {
            if ($HBABios -is [system.array]) { #WMI could return object as array
                #length, urobit iteracie polom a najst prvy occurenece qlogic stringu v manufacturer property
                $HBABiosVersion = $HBABios[0].VersionString + ";"
            }
            else {
                $HBABiosVersion = $HBABios.VersionString
                if ($HBABiosVersion -isnot [system.array]) { #check if there are more than one result, if it is, variable becomes an array of objects and needs to be processed accordingly
                    $HBABiosVersion = $HBABiosVersion + ";"
                }
                else {
                    $HBABiosVersion = $HBABiosVersion[0] + ";"
                }
            }
        }
        else {
            $HBABiosVersion = "no version;"
        }
        
        #NIC Firmware
        $nicFW = gwmi -class "HP_WinEthBootcodeVersion" -namespace "root\HPQ"
        if ($nicFW) {
            if ($nicFW -is [system.array]) { #WMI could return object as array
                $nicFWVersion = $nicFW[0].VersionString + ";"
            }
            else {
                $nicFWversion = $nicFW.VersionString
                if ($nicFWversion -isnot [system.array]) { #check if there are more than one result, if it is, variable becomes an array of objects and needs to be processed accordingly
                    $nicFWversion = $nicFWversion + ";"
                }
                else {
                    $nicFWVersion = $nicFWversion[0] + ";"
                }
            }
        }
        else {
            $nicFWversion = "no version;"
        }

        #NIC driver
        $NICpath = (gwmi win32_systemdriver | Where {$_.displayname -match 'emulex'}).pathname
        if ($NICpath) {
            $NICversionInfo = (((get-item $NICpath).versioninfo).fileversion)
            $NICString = $NICversionInfo.split(' ')
            $NICDrvVersion = $NICString[0] + ";"
        }
        else {
            $NICDrvVersion = "no version;"
        }

        #SMH version
        $smh = gwmi -class "CIM_SoftwareIdentity" -namespace "root\HPQ" | Where {$_.caption -match "system management homepage"}
        if ($smh) {
            $smhVersion = $smh.VersionString + ";"
        }
        else {
            $smhVersion = "no version;"
        }
        
        #iLO version
        $ilo = gwmi -class "CIM_SoftwareIdentity" -namespace "root\HPQ" | Where {$_.caption -match "Management Processor Firmware"}
        if ($ilo) {
            $iloVersion = $ilo.VersionString + ";"
        }
        else {
            $iloVersion = "no version;"
        }
        
        #SPP version
        #version control agent nemusi byt na vsetkych masinach, lepsie je kontrolovat insight management agents
        $spp = gwmi win32_product | where {$_.name -match "version control agent"}
        if ($spp) {
            $sppVersion = $spp.VersionString + ";"
        }
        else {
            $sppVersion = "no version;"
        }
        
        #MPIO Driver version
        if ($MPIODrvVersion = (Get-Item C:\Windows\System32\drivers\mpio.sys).VersionInfo.FileVersion) {
            
        }
        else {
            $MPIODrvVersion = "no version;"
        }
    }
    else {
        $smartArrayFW = "no WBEM providers;"
        $smartArrayDrvVersion = "no WBEM providers;"
        $HBADriverVersion = "no WBEM providers;"
        $HBAfirmware = "no WBEM providers;"
        $HBABiosVersion = "no WBEM providers;"
        $nicFWversion = "no WBEM providers;"
        $NICDrvVersion = "no WBEM providers;"
        $smhVersion = "no WBEM providers;"
        $iloVersion = "no WBEM providers;"
        $sppVersion = "no WBEM providers;"
        $MPIODrvVersion = "no WBEM providers;"
    }
    
}
if ($model -eq "VMware;") { #block for VMware
    $vmtools = gwmi win32_product | where {$_.name -match "VMware Tools"} #if it is VMware, bios version is replaced with VM tools version
    $serialNumber = $vmtools.Version + ";"
}
if ($model -eq "Hyper-V;") { #block for Hyper-V
}

$resultString = ";" + $computerName
$resultString += $customerName
$resultString += $OSVersion
$resultString += $servicePack
$resultString += $OSarchitecture
$resultString += $isCluster
$resultString += $model
$resultString += $serialNumber
$resultString += $biosVersion
$resultString += $ovoVersion
$resultString += $dpVersion
$resultString += $hpsaVersion
$resultString += $smartArrayFW
$resultString += $smartArrayDrvVersion
$resultString += $HBADriverVersion
$resultString += $HBAfirmware
$resultString += $HBABiosVersion
$resultString += $nicFWversion
$resultString += $NICDrvVersion
$resultString += $smhVersion
$resultString += $iloVersion
$resultString += $sppVersion
$resultString += $MPIODrvVersion


#saving check also to file on a server
$path = "C:\temp\San_Compl_Check" #location of a folder
if (Test-path $path) { #test if folder exists
    #do nothing
}
else {
    New-Item -ItemType directory -Path C:\temp\San_Compl_Check #create folder
}
$dateTime = Get-Date -Uformat "%d-%m-%Y__%H-%M"
$resultLocation = "C:\temp\San_Compl_Check\San_Compl_Result`_$dateTime.csv"
Add-Content $resultLocation $resultString

write-host $resultString #writing result on a screen