function Get-PCRemote { param ( [string]$comp, [int]$NumberofComputers, [int]$PCID ) $compstatus = "Online" $i = 0 $i++ | ProgressBar $i $comp "ipV4" $NumberofComputers $PCID $ipV4 = Get-PCIPAddress $comp $i++ | ProgressBar $i $comp "MAC" $NumberofComputers $PCID $mac = Get-PCMACAddress $comp $i++ | ProgressBar $i $comp "Adapter" $NumberofComputers $PCID $adapter = Get-PCAdapter $comp $i++ | ProgressBar $i $comp "Usernames" $NumberofComputers $PCID $userName = Get-PCUserName $comp $i++ | ProgressBar $i $comp "Computer Model" $NumberofComputers $PCID $compModel = Get-PCCompModel $comp $i++ | ProgressBar $i $comp "RAM Size" $NumberofComputers $PCID $compMemory = Get-PCCompMemory $comp $i++ | ProgressBar $i $comp "HDD/SSD Space" $NumberofComputers $PCID $compFreeSpace = Get-PCCompFreeSpace $comp $i++ | ProgressBar $i $comp "Service Tag" $NumberofComputers $PCID $compServiceTag = Get-PCCompServiceTag $comp $i++ | ProgressBar $i $comp "Bios Version" $NumberofComputers $PCID $compBiosVersion = Get-PCCompBiosVersion $comp $i++ | ProgressBar $i $comp "Last Boot Time" $NumberofComputers $PCID $compLastBootUpTime = Get-PCCompLastBootUpTime $comp $i++ | ProgressBar $i $comp "Asset Tag" $NumberofComputers $PCID $compAssetTag = Get-PCCompAssetTag $comp $i++ | ProgressBar $i $comp "Encryption" $NumberofComputers $PCID $hasBitLocker = Get-PCHasBitLocker $comp $i++ | ProgressBar $i $comp "OS Version" $NumberofComputers $PCID $compOSVersion = Get-PCCompOSVersion $comp $i++ | ProgressBar $i $comp "OS Architecture" $NumberofComputers $PCID $compArchitectureBuild = Get-PCCompArchitectureBuild $comp $i++ | ProgressBar $i $comp "OS Build #" $NumberofComputers $PCID $compOSBuildNumber = Get-PCCompOSBuildNumber $comp $i++ | ProgressBar $i $comp "Drive Type" $NumberofComputers $PCID $driveType = Get-PCDriveType $comp $i++ | ProgressBar $i $comp "Citrix Version" $NumberofComputers $PCID $citrixVersion = Get-PCCitrixVersion $comp $i++ | ProgressBar $i $comp "CPU Type" $NumberofComputers $PCID $compCPU = Get-CPUType $comp $i++ | ProgressBar $i $comp "Chassis Type" $NumberofComputers $PCID $chassisType = Get-ChassisType $compCPU $compModel $i++ | ProgressBar $i $comp "Last Users" $NumberofComputers $PCID $lastUser = Get-PCLastUser $comp $i++ | ProgressBar $i $comp "Time Stamp" $NumberofComputers $PCID $lastUserTimeStamp = Get-PCLastUserTimeStamp $comp if($lastUser.Count -gt 1){ $lastUser1 = ($lastUser[0] + "-(" + $lastUserTimeStamp[0] + ")").Split("-") $lastUser2 = ($lastUser[1] + "-(" + $lastUserTimeStamp[1] + ")").Split("-") $lastUser3 = ($lastUser[2] + "-(" + $lastUserTimeStamp[2] + ")").Split("-") $TotalLastUsers = "$lastUser1 $lastUser2 $lastUser3" }else{ $TotalLastUsers = "$lastUser ($lastUserTimeStamp)" } $i++ | ProgressBar $i $comp "Imprivata Type" $NumberofComputers $PCID #This command determines if it isget-p a SUD or MUD. 0 = SUD, 1 = MUD $imprivataType = Get-PCImprivataType $comp $i++ | ProgressBar $i $comp "Kiosk Role" $NumberofComputers $PCID #Determines if the kiosk role, example "Exam Room" $kioskRole = Get-PCKioskRole $comp $i++ | ProgressBar $i $comp "Kiosk Type" $NumberofComputers $PCID #This command returns either 1 or 2. 1 = "SUD/MUD", 2 = "Kiosk" $kioskType = Get-PCKioskType $comp $i++ | ProgressBar $i $comp "ReleaseID" $NumberofComputers $PCID #This command returns the OS Version $releaseID = Get-PCReleaseID $comp $i++ | ProgressBar $i $comp "Printers" $NumberofComputers $PCID #This command pulls any printers connected/installed onto the current PC $getPrinter = Get-PCPrinter $comp $i++ | ProgressBar $i $comp "GPO Status" $NumberofComputers $PCID $getGPOStatus = Get-GPOStatus $comp $i++ | ProgressBar $i $comp "TPM Status" $NumberofComputers $PCID $tpmStatus = Get-TPMStatus $comp if($compOSVersion -ne "Microsoft Windows 10 Enterprise"){ $driveType = "(Drive Type: Unavailable on Win 7)" } Switch($kioskType) { 1 {} 2 {$imprivataType = "Kiosk"} } if($imprivataType -eq "Kiosk" -and $getPrinter -ne '') #Checks if PC is a Kiosk with a locally/networked installed Printer { $getPrinter = $getPrinter + " (Check Epic Printer Mappings)" } elseif($imprivataType -eq "Kiosk" -and !$getPrinter) #Checks if PC is a Kiosk and does not have a locally/networked installed Printer { $getPrinter = "Check Epic Printer Mappings" } elseif(!$getPrinter) { $getPrinter = "No Local/Networked Printer (Check Printer Mappings)" } if(!$kioskRole) { $kioskRole = "N/A" } if(!$userName) { $userName = "**None**" } if(!$compAssetTag) { $compAssetTag = "(N/A in SMBios)" } $compFreeSpaceGB = [math]::Round(($compFreeSpace[0] / 1GB),2) #$compFreeSpaceMB = [math]::Round(($compFreeSpace[0] / 1MB)) $compMemory = [math]::Round(($compMemory / 1GB)) $compFreeSpaceMB = "$compFreeSpaceMB" + ' MB' $compFreeSpaceGB = "$compFreeSpaceGB" + ' GB' $compMemory = "$compMemory" + ' GB' $i++ | ProgressBar $i $comp "Generating Output" $NumberofComputers $PCID $props = [Ordered]@{ Hostname = "$comp" Status = "$compStatus" 'Current User' = "$userName" 'Last User(s)' = "$TotalLastUsers" 'IP | MAC' = "$ipV4 | $mac" 'Adapter' = "$adapter" Model = "$compModel ($chassisType)" 'OS' = "$compOSVersion" + " ($compArchitectureBuild)" 'OS Build' = "Vers #$releaseID |" + " Build #$compOSBuildNumber" 'BIOS Ver' = "$compBiosVersion" Encryption = "$hasBitLocker" 'Free Space' = "$compFreeSpaceGB " + "/ " + $compfreeSpace[1] + " GB | $driveType" RAM = "$compMemory" 'SSO Client' = "$imprivataType" 'Kiosk Role' = "$kioskRole" 'Citrix Ver' = "$citrixVersion" 'Asset Tag' = "$compAssetTag" 'Service Tag' = "$compServiceTag" 'Last Reboot' = "$compLastBootUpTime" 'TPM Status' = "$tpmStatus" 'MBAM GPO' = "$getGPOStatus" Printers = "$getPrinter" } $obj = New-Object -TypeName PSObject -Property $props return $obj } Function Get-PCIPAddress ($ComputerName){ $ipV4 = Test-Connection -ComputerName ($ComputerName) -Count 1 | Select-Object -ExpandProperty IPV4Address Return $ipV4 } Function Get-PCMACAddress ($ComputerName){ $mac = (Get-CimInstance win32_networkadapterconfiguration -ComputerName ($ComputerName) | Where-Object {$_.IpEnabled -Match "True"} | Select-Object -Expand macaddress) -join "," Return $mac } Function Get-PCAdapter ($ComputerName){ $adapter = (Get-CimInstance win32_networkadapterconfiguration -ComputerName ($ComputerName) | Where-Object {$_.IpEnabled -Match "True"} | Select-Object -Expand Description) if($adapter -is [array]){ $adapter = $adapter[0] } Return $adapter } Function Get-PCUserName ($ComputerName){ $Username = (Get-CimInstance -Class win32_computersystem -ComputerName $ComputerName).UserName if($null -eq $Username){ $Username = (Invoke-Command {Get-Process Explorer -IncludeUsername | Where-Object { $_.Username -notlike "*SYSTEM" }} -SessionOption (New-PSSessionOption -NoMachineProfile) -ComputerName $ComputerName).Username if($null -ne $Username){ $Username = "$Username (RDP/Inactive)" } } Return $Username } Function Get-PCCompModel ($ComputerName){ $CompModel = (Get-CimInstance -ClassName Win32_ComputerSystem -ComputerName $ComputerName).Model #| Select -ExpandProperty Model Return $CompModel } Function Get-PCCompMemory ($ComputerName){ $CompMemory = (Get-CimInstance -ClassName Win32_ComputerSystem -ComputerName $ComputerName).TotalPhysicalMemory #| Select -ExpandProperty TotalPhysicalMemory Return $CompMemory } Function Get-PCCompFreeSpace ($ComputerName){ $CompFreeSpace = Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DriveType=3" -ComputerName $ComputerName | Measure-Object -Property FreeSpace -Sum | Select-Object -ExpandProperty Sum $TotalSpace = (Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DriveType=3" -ComputerName $ComputerName | Select-Object -ExpandProperty Size) / 1GB $out = @($CompFreeSpace,[math]::Round($TotalSpace,2)) Return $out } Function Get-PCCompServiceTag ($ComputerName){ $CompServiceTag = (Get-CimInstance -Class win32_bios -ComputerName $ComputerName).SerialNumber #| Select -ExpandProperty SerialNumber Return $CompServiceTag } Function Get-PCCompBiosVersion ($ComputerName){ $CompBiosVersion = (Get-CimInstance -Class win32_bios -ComputerName $ComputerName).SMBIOSBIOSVersion #| Select -ExpandProperty SMBIOSBIOSVersion Return $CompBiosVersion } Function Get-PCCompLastBootUpTime ($ComputerName){ $CompLastBootUpTime = (Get-CimInstance Win32_OperatingSystem -ComputerName $ComputerName).LastBootUpTime Return $CompLastBootUpTime } Function Get-PCCompAssetTag ($ComputerName){ $CompAssetTag = (Get-CimInstance Win32_SystemEnclosure -ComputerName $ComputerName).SMBiosAssetTag Return $CompAssetTag } Function Get-PCHasBitLocker ($ComputerName){ $bitlocker = manage-bde -ComputerName $ComputerName -status C: $PercentageEncrypted = ((manage-bde -ComputerName $ComputerName -status C: | Select-String "Percentage Encrypted") -split ': ')[1] [int]$IntPercentageEncrypted = $PercentageEncrypted.Substring(0,4) If($bitlocker -like '*error*') { $EncryptionStatus = 'BitLocker - Error - Please investigate' Return $EncryptionStatus } Elseif($IntPercentageEncrypted -eq 100) { $EncryptionStatus = "BitLocker - Encrypted ($PercentageEncrypted)" Return $EncryptionStatus } ElseIf($IntPercentageEncrypted -gt 1) { $EncryptionStatus = "BitLocker - Encrypting ($PercentageEncrypted)" Return $EncryptionStatus } Else { $EncryptionStatus = "BitLocker - Decrypted ($PercentageEncrypted)" Return $EncryptionStatus } } Function Get-PCCompOSVersion ($ComputerName){ $CompOSVersion = Get-CimInstance win32_operatingsystem -ComputerName $ComputerName | ForEach-Object caption Return $CompOSVersion } Function Get-PCCompArchitectureBuild ($ComputerName){ $CompArchitectureBuild = (Get-CimInstance -ClassName Win32_OperatingSystem -ComputerName $ComputerName).OSArchitecture Return $CompArchitectureBuild } Function Get-PCCompOSBuildNumber ($ComputerName){ $CompOSBuildNumber = (Get-CimInstance -ClassName Win32_OperatingSystem -ComputerName $ComputerName).BuildNumber Return $CompOSBuildNumber } Function Get-PCDriveType ($ComputerName){ $DriveType = New-CimSession $ComputerName #Create a CIM SESSION with PC name $DriveType = Get-PhysicalDisk -CimSession $ComputerName | Select-Object -ExpandProperty MediaType #Access CimSession that we created before Remove-CimSession $ComputerName #closes the CIM-SESSION Return $DriveType } Function Get-PCCitrixVersion ($ComputerName){ $CitrixViewer = "\\$ComputerName\C$\Program Files (X86)\Citrix\ICA Client\CDViewer.exe" #Checks this default install path $CitrixVersion = Get-Command $citrixViewer | select-object -ExpandProperty Version #Grabs Citrix version number #checks if Citrix is in the correct path if( !(Test-path $CitrixViewer)){ $CitrixVersion = "Not Installed" } Return $CitrixVersion } Function Get-PCLastUser ($ComputerName){ $LastUser = Invoke-Command -ComputerName $ComputerName -SessionOption (New-PSSessionOption -NoMachineProfile) -ScriptBlock { Get-ChildItem -Path C:\Users -Directory -Force -Exclude Public,Default,'Default User','All Users' | Sort-Object -Property LastWriteTime -Descending | Select-Object -First 3 -ExpandProperty Name} Return $LastUser } Function Get-PCLastUserTimeStamp ($ComputerName){ $LastUserTimeStamp = Invoke-Command -ComputerName $ComputerName -SessionOption (New-PSSessionOption -NoMachineProfile) -ScriptBlock { Get-ChildItem -Path C:\Users -Directory -Force -Exclude Public,Default,'Default User','All Users' | Sort-Object -Property LastWriteTime -Descending | Select-Object -First 3 -ExpandProperty LastWriteTime } Return $LastUserTimeStamp } Function Get-PCImprivataType ($ComputerName){ $ImprivataType = Invoke-Command -ComputerName $ComputerName -SessionOption (New-PSSessionOption -NoMachineProfile) -ScriptBlock { Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\SSOProvider\ISXAgent | Select-Object -ExpandProperty FUS_Enabled } if($null -eq $ImprivataType){ $ImprivataType = 2 } Switch($ImprivataType) { 0 {$ImprivataType = "SUD"} 1 {$ImprivataType = "MUD"} Default {$ImprivataType = "Imprivata Agent not Installed"} } Return $ImprivataType } Function Get-PCKioskRole ($ComputerName){ $KioskRole = Invoke-Command -ComputerName $ComputerName -SessionOption (New-PSSessionOption -NoMachineProfile) -ScriptBlock { Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\SHSCustom | Select-Object -ExpandProperty KioskRole } Return $KioskRole } Function Get-PCKioskType ($ComputerName){ $KioskType = Invoke-Command -ComputerName $ComputerName -SessionOption (New-PSSessionOption -NoMachineProfile) -ScriptBlock { Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\SSOProvider\ISXAgent | Select-Object -ExpandProperty Type} Return $KioskType } Function Get-PCReleaseID ($ComputerName){ $ReleaseID = Invoke-Command -ComputerName $ComputerName -SessionOption (New-PSSessionOption -NoMachineProfile) -ScriptBlock { (Get-Item "HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion").GetValue('ReleaseID') } Return $ReleaseID } Function Get-PCPrinter ($ComputerName){ $GetPrinter = Invoke-Command -ComputerName $ComputerName -SessionOption (New-PSSessionOption -NoMachineProfile) -ScriptBlock { (Get-CimInstance -Class Win32_Printer | Where-Object -Property PortName -ne nul: | Where-Object -Property PortName -ne PORTPROMPT: | Where-Object -Property PortName -ne SHRFAX: | Select-Object -ExpandProperty Name) -join ' || '} Return $GetPrinter } Function Get-TPMStatus ($ComputerName){ $tpmStatus = Get-WmiObject -Namespace root\cimv2\security\microsofttpm -Class win32_tpm -ComputerName $ComputerName | Select-Object -ExpandProperty IsEnabled_InitialValue #Determine TPM Status if($tpmStatus -eq $true) { $tpmStatus = "On & Activated" } elseif($tpmStatus -eq $false) { $tpmStatus = "On & Deactivated" } else { $tpmStatus = "TPM Off" } Return $tpmStatus } Function Get-GPOStatus ($ComputerName){ Invoke-Command -ComputerName $ComputerName -SessionOption (New-PSSessionOption -NoMachineProfile) -ScriptBlock{ $gpoPath = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\FVE\MDOPBitLockerManagement" $gpoValue = Get-ItemPropertyValue -Path $gpoPath -Name "KeyRecoveryServiceEndPoint" Switch($GpoValue -eq "https://shsmbam1.int.samhealth.net/MBAMRecoveryAndHardwareService/CoreService.svc") { $true {$gpoStatus = "GPO Applied"} $false {$gpoStatus = "GPO Not Applied (Check if system is member of group MBAM_Default on ADUC"} Default {$gpoStatus = "Error...GPOTEST Line PCRemote Line 276"} } Return $gpoStatus } } Function Get-CPUType ($ComputerName){ $CPU = (Get-CimInstance -ClassName Win32_processor -ComputerName $ComputerName).Name Return $CPU } #If updating (Get-ChassisType), make sure to update the PCLocal & SCCMQuery module as well Function Get-ChassisType ($CPU, $Model){ Switch -Wildcard($Model) { "Optiplex*" { Switch -Wildcard($CPU) { "Intel(R) Core(TM) i5-9500 CPU*" {Return "SFF"} #5070 "Intel(R) Core(TM) i5-6500 CPU*" {Return "SFF"} #7040 "Intel(R) Core(TM) i5-6500T*" {Return "Micro"} #7040 "Intel(R) Core(TM) i7-6700 CPU*" {Return "SFF"} #7040 "Intel(R) Core(TM) i7-6700T*" {Return "Micro"} #7040 "Intel(R) Core(TM) i5-10500T*" {Return "Micro"} #5080 "Intel(R) Core(TM) i5-9500T*" {Return "Micro"} #5070 "Intel(R) Core(TM) i5-8500 CPU*" {Return "SFF"} #5060 "Intel(R) Core(TM) i5-8500T*" {Return "Micro"} #5060 "Intel(R) Core(TM) i5-7500*" {Return "SFF"} #5050 "Intel(R) Core(TM) i5-4670 CPU*" {Return "SFF"} #9020 "Intel(R) Core(TM) i5-4590 CPU*" {Return "SFF"} #9020 "Intel(R) Core(TM) i5-4590T CPU*" {Return "Micro"} #9020M "Intel(R) Core(TM) i5-4690 CPU*" {Return "SFF"} #9020 "Intel(R) Core(TM) i5-3550 CPU*" {Return "SFF"} #9010 "Intel(R) Core(TM) i5-2400 CPU*" {Return "SFF"} #990 Default {Return "Optiplex - Chassis Type - Unknown"} } } "Latitude*" { Return "Laptop" } "Precision*"{ Return "Laptop" } "M24*" { return "Anesthesia Cart" } "Medix*"{ return "Anesthesia Cart" } Default {Return "Unknown Model/Chassis"} } } <# Function Get-CMDBLocation { $cmdb = Get-LANDeskCMDBItem -Name $comp if ($null -eq $cmdb){ $location = "*CMDB Mismatch - check CMDB*" return $location } $location = $cmdb.values._SHSLocation3 if($null -eq $location -or '' -eq $location){ $location = "*No location data - Please update CMDB*" } return $location } #> ##STILL TESTING Function Get-TimeOutJob ($Command){ $Job = Start-Job -ScriptBlock { $test1 = $Command Return $test1 $Job | Wait-Job -Timeout 2 $Job | Stop-Job } }