Refactored and fixed mobile devices bug
This commit is contained in:
parent
649ed498b5
commit
ddd1f02fed
|
|
@ -12,7 +12,7 @@
|
|||
RootModule = 'Get-PC.psm1'
|
||||
|
||||
# Version number of this module.
|
||||
ModuleVersion = '0.4.7'
|
||||
ModuleVersion = '0.4.8'
|
||||
|
||||
# Supported PSEditions
|
||||
# CompatiblePSEditions = @()
|
||||
|
|
|
|||
|
|
@ -5,369 +5,6 @@ function Get-PCBatchInvoke {
|
|||
[string[]]
|
||||
$Computers
|
||||
)
|
||||
$Tenant = (Connect-ISM)[1]
|
||||
$Headers = (Connect-ISM)[0]
|
||||
#Region Script Block
|
||||
$sblock = {
|
||||
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 10
|
||||
try {$win32_networkadapterconfiguration = Get-CimInstance -Class win32_networkadapterconfiguration} catch {$win32_networkadapterconfiguration = $null} #| MAC Address,
|
||||
try {$win32_LogicalDisk = Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DriveType=3" } catch {$win32_LogicalDisk = $null} #| Diskspace,
|
||||
try {$win32_SystemEnclosure = Get-CimInstance -ClassName Win32_SystemEnclosure} catch {$win32_SystemEnclosure = $null} #| Asset Tag
|
||||
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 20
|
||||
try {$bitlocker = manage-bde -status C:} catch {$bitlocker = $null} # | Bitlocker Status
|
||||
try {$PCInfo = get-computerinfo} catch {$PCInfo = $null}
|
||||
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 30
|
||||
try {$physicalDisk = Get-PhysicalDisk} catch {$physicalDisk = $null} # | Disk Type
|
||||
try {$win32_printer = (Get-CimInstance -ClassName win32_printer | Where-Object {$_.PortName -ne 'PORTPROMPT:' -and $_.PortName -ne 'nul:' -and $_.PortName -ne 'SHRFAX:'} | Select-Object -ExpandProperty Name) -join ' || ' }
|
||||
catch{ $win32_printer = $null} # | Printers
|
||||
try {$imprivataRegEntry = Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\SSOProvider\ISXAgent} catch {$imprivataRegEntry = $null}
|
||||
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 40
|
||||
try {$kioskRegEntry = Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\SHSCustom} catch {$kioskRegEntry = $null}
|
||||
try {$win32_tpm = Get-CimInstance -Namespace root\cimv2\security\microsofttpm -Class win32_tpm} catch{$win32_tpm = $null} # | TPM
|
||||
|
||||
$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"}
|
||||
}
|
||||
|
||||
|
||||
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 50
|
||||
$CitrixViewer = "C:\Program Files (X86)\Citrix\ICA Client\CDViewer.exe"
|
||||
#$LastUser = Get-ChildItem -Path C:\Users -Directory -Force -Exclude Public,Default,'Default User','All Users' | Sort-Object -Property LastWriteTime -Descending | Select-Object -First 3 # | Last Users
|
||||
try {$CPU = (Get-CimInstance -ClassName Win32_processor ).Name } catch {$CPU = $null}
|
||||
|
||||
|
||||
#MAC Address
|
||||
$MAC = ($win32_networkadapterconfiguration | Where-Object {$_.IpEnabled -Match "True"} | Select-Object -Expand macaddress) -join ","
|
||||
|
||||
#IP
|
||||
$ip = ($win32_networkadapterconfiguration | Where-Object {$_.IpEnabled -Match "True"} | Select-Object -Expand IPAddress)
|
||||
if($ip -is [array]){
|
||||
$ip = $ip[0]
|
||||
}
|
||||
|
||||
#Adapter
|
||||
$adapter = ($win32_networkadapterconfiguration | Where-Object {$_.IpEnabled -Match "True"} | Select-Object -Expand Description)
|
||||
<#
|
||||
if($adapter -is [array]){
|
||||
$adapter = $adapter[0]
|
||||
}
|
||||
#>
|
||||
|
||||
#UserName
|
||||
$Username = $PCInfo.CSUserName
|
||||
if($null -eq $Username){
|
||||
|
||||
$Username = (Invoke-Command -SessionOption (New-PSSessionOption -NoMachineProfile) -ScriptBlock {Get-Process Explorer -IncludeUsername | Where-Object { $_.Username -notlike "*SYSTEM" }} ).Username
|
||||
|
||||
if($null -ne $Username){
|
||||
$Username = "$Username (RDP/Inactive)"
|
||||
}
|
||||
else{
|
||||
$Username = '**None**'
|
||||
}
|
||||
}
|
||||
|
||||
#Collecting most recent users from the registry
|
||||
$lastuser = @()
|
||||
$profiles = Get-CimInstance -Class Win32_UserProfile
|
||||
$profiles | Where-Object {$_.SID.length -gt 10} | Foreach-Object {
|
||||
|
||||
$sid = $_.SID
|
||||
$prop = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\$sid\"
|
||||
|
||||
if($prop.LocalProfileUnLoadTimeHigh -and $prop.LocalProfileUnLoadTimeLow){
|
||||
$a = '{0:x}' -f $prop.LocalProfileUnLoadTimeHigh
|
||||
$b = '{0:x}' -f $prop.LocalProfileUnLoadTimeLow
|
||||
$dec = [bigint]::Parse("$a$b",'AllowHexSpecifier')
|
||||
$time = w32tm /ntte $dec
|
||||
$lastTime = [datetime]($time -split ' - ')[1]
|
||||
}
|
||||
else{
|
||||
$lastTime = "Unknown"
|
||||
}
|
||||
|
||||
$obj = [PSCustomObject]@{
|
||||
Name = ($_.LocalPath -split 'C:\\Users\\')[1]
|
||||
LocalPath = $_.LocalPath
|
||||
LastLoginTime = $lastTime
|
||||
}
|
||||
$lastuser += $obj
|
||||
}
|
||||
|
||||
$lastuser = $lastuser | Where-Object LastLoginTime -ne 'Unknown' | Sort-Object LastLoginTime -Descending
|
||||
#Last User
|
||||
if($lastUser.Count -gt 1){
|
||||
|
||||
$lastUser1 = ($lastUser[0].Name + " (" + $lastUser[0].LastLoginTime + ")")
|
||||
$lastUser2 = ($lastUser[1].Name + " (" + $lastUser[1].LastLoginTime + ")")
|
||||
$lastUser3 = ($lastUser[2].Name + " (" + $lastUser[2].LastLoginTime + ")")
|
||||
|
||||
$TotalLastUsers = "$lastUser1 $lastUser2 $lastUser3"
|
||||
|
||||
}else{
|
||||
|
||||
$TotalLastUsers = $lastUser.Name + " (" + $lastUser.LastLoginTime + ")"
|
||||
}
|
||||
#ComputerModel
|
||||
$Model = $PCInfo.CsModel
|
||||
|
||||
#RAM
|
||||
$totalram = $PCInfo.CsTotalPhysicalMemory
|
||||
$totalram = [math]::Round(($totalram / 1GB))
|
||||
$ram = "$totalram GB"
|
||||
|
||||
#Drive Type
|
||||
$DriveType = $physicalDisk.MediaType
|
||||
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 60
|
||||
#Free Harddrive Space
|
||||
$CompFreeSpace = @([math]::Round($win32_LogicalDisk.FreeSpace / 1gb,2),[math]::Round($win32_LogicalDisk.Size / 1gb,2))
|
||||
$free = $compFreeSpace[0]
|
||||
$max = $compfreeSpace[1]
|
||||
$freespace = "$free GB / $max GB"
|
||||
|
||||
|
||||
#Service Tag
|
||||
#$serviceTag = $win32_bios.SerialNumber
|
||||
$serviceTag = $PCInfo.BiosSeralNumber
|
||||
#BIOS
|
||||
#$biosVersion = $win32_bios.SMBIOSBIOSVersion
|
||||
$biosVersion = $PCInfo.BiosName
|
||||
|
||||
#Last Reboot
|
||||
$lastbootTime = $PCInfo.OsLastBootUpTime
|
||||
|
||||
#Asset Tag
|
||||
$assetTag = $win32_SystemEnclosure.SMBiosAssetTag
|
||||
|
||||
#Bitlocker Status
|
||||
$PercentageEncrypted = (($bitlocker | Select-String "Percentage Encrypted") -split ': ')[1]
|
||||
[int]$IntPercentageEncrypted = $PercentageEncrypted.Substring(0,4)
|
||||
$EncryptionStatus = $null
|
||||
If($bitlocker -like '*error*')
|
||||
{
|
||||
$EncryptionStatus = 'BitLocker - Error - Please investigate'
|
||||
}
|
||||
Elseif($IntPercentageEncrypted -eq 100)
|
||||
{
|
||||
$EncryptionStatus = "BitLocker - Encrypted ($PercentageEncrypted)"
|
||||
}
|
||||
ElseIf($IntPercentageEncrypted -gt 1)
|
||||
{
|
||||
$EncryptionStatus = "BitLocker - Encrypting ($PercentageEncrypted)"
|
||||
}
|
||||
Else
|
||||
{
|
||||
$EncryptionStatus = "BitLocker - Decrypted ($PercentageEncrypted)"
|
||||
}
|
||||
|
||||
#OS
|
||||
$os = $PCInfo.OSName + " (" + $PCInfo.OSArchitecture + ")"
|
||||
|
||||
#OS Build
|
||||
$osVer = $PCInfo.WindowsVersion
|
||||
if($osVer -gt 2004){
|
||||
$osVer = (Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion").DisplayVersion
|
||||
}
|
||||
$osBuild = $PCInfo.OSBuildNumber
|
||||
$osBuild = "Vers $osVer | Build #$osBuild"
|
||||
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 70
|
||||
#Printers
|
||||
$printers = $win32_printer# ($win32_printer | Where-Object {$_.PortName -ne 'PORTPROMPT:' -and $_.PortName -ne 'nul:' -and $_.PortName -ne 'SHRFAX:'} | Select-Object -ExpandProperty Name) -join ' || '
|
||||
if(!$printers){
|
||||
$printers = "No Local/Networked Printer (Check Printer Mappings)"
|
||||
}
|
||||
|
||||
#Imprivata
|
||||
$ImprivataType = $imprivataRegEntry | Select-Object -ExpandProperty Type
|
||||
if(!$imprivataType){
|
||||
$ImprivataType = "Not Installed"
|
||||
}
|
||||
else{
|
||||
Switch($ImprivataType){
|
||||
1 {
|
||||
$ImprivataType = $imprivataRegEntry | Select-Object -ExpandProperty FUS_Enabled
|
||||
Switch($ImprivataType){
|
||||
0 {$ImprivataType = "SUD"}
|
||||
1 {$ImprivataType = "MUD"}
|
||||
}
|
||||
}
|
||||
2 {$ImprivataType = "Kiosk"}
|
||||
Default {$ImprivataType = "Not Installed"}
|
||||
}
|
||||
}
|
||||
$kioskRole = try {$kioskRegEntry | Select-Object -ExpandProperty KioskRole} catch{ $null }
|
||||
if (!$kioskRole) { $kioskRole = "None"}
|
||||
|
||||
#TPM
|
||||
if($win32_tpm){
|
||||
$tpmVersion = " | Vers " + $win32_tpm.ManufacturerVersionFull20
|
||||
$tpmStatus = "On"
|
||||
if($win32_tpm.IsActivated_InitialValue){
|
||||
$tpmStatus += ", Activated"
|
||||
}
|
||||
else{
|
||||
$tpmStatus += ", Not Activated"
|
||||
}
|
||||
if($win32_tpm.IsEnabled_InitialValue){
|
||||
$tpmStatus += ", Enabled"
|
||||
}
|
||||
else {
|
||||
$tpmStatus += ", Disabled"
|
||||
}
|
||||
if($win32_tpm.IsOwned_InitialValue){
|
||||
$tpmStatus += ", Owned"
|
||||
}
|
||||
else{
|
||||
$tpmStatus += ", Not Owned"
|
||||
}
|
||||
$tpmStatus += $tpmVersion
|
||||
}
|
||||
else {
|
||||
$tpmStatus = "Off"
|
||||
}
|
||||
|
||||
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 80
|
||||
#Citrix Version
|
||||
if( !(Test-path $CitrixViewer)){
|
||||
|
||||
$CitrixVersion = "Not Installed"
|
||||
}
|
||||
else{
|
||||
#Checks this default install path
|
||||
$CitrixVersion = Get-Command $citrixViewer | select-object -ExpandProperty Version #Grabs Citrix version number
|
||||
}
|
||||
|
||||
#Chassis Type
|
||||
|
||||
Switch -Wildcard($Model) {
|
||||
"Optiplex*" {
|
||||
Switch -Wildcard($CPU)
|
||||
{
|
||||
"Intel(R) Core(TM) i5-9500 CPU*" {$chassisType = "SFF"} #5070
|
||||
|
||||
"Intel(R) Core(TM) i5-6500 CPU*" {$chassisType = "SFF"} #7040
|
||||
|
||||
"Intel(R) Core(TM) i5-6500T*" {$chassisType = "Micro"} #7040
|
||||
|
||||
"Intel(R) Core(TM) i7-6700 CPU*" {$chassisType = "SFF"} #7040
|
||||
|
||||
"Intel(R) Core(TM) i7-6700T*" {$chassisType = "Micro"} #7040
|
||||
|
||||
"Intel(R) Core(TM) i5-10500T*" {$chassisType = "Micro"} #5080
|
||||
|
||||
"Intel(R) Core(TM) i5-9500T*" {$chassisType = "Micro"} #5070
|
||||
|
||||
"Intel(R) Core(TM) i5-8500 CPU*" {$chassisType = "SFF"} #5060
|
||||
|
||||
"Intel(R) Core(TM) i5-8500T*" {$chassisType = "Micro"} #5060
|
||||
|
||||
"Intel(R) Core(TM) i5-7500*" {$chassisType = "SFF"} #5050
|
||||
|
||||
"Intel(R) Core(TM) i5-4670 CPU*" {$chassisType = "SFF"} #9020
|
||||
|
||||
"Intel(R) Core(TM) i5-4590 CPU*" {$chassisType = "SFF"} #9020
|
||||
|
||||
"Intel(R) Core(TM) i5-4590T CPU*" {$chassisType = "Micro"} #9020M
|
||||
|
||||
"Intel(R) Core(TM) i5-4690 CPU*" {$chassisType = "SFF"} #9020
|
||||
|
||||
"Intel(R) Core(TM) i5-3550 CPU*" {$chassisType = "SFF"} #9010
|
||||
|
||||
"Intel(R) Core(TM) i5-2400 CPU*" {$chassisType = "SFF"} #990
|
||||
|
||||
Default {$chassisType = "Optiplex - Chassis Type - Unknown"}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
"Latitude*" {
|
||||
$chassisType = "Laptop"
|
||||
}
|
||||
"Precision*"{
|
||||
$chassisType = "Laptop"
|
||||
}
|
||||
"M24*" {
|
||||
$chassisType = "Anesthesia Cart"
|
||||
}
|
||||
"Medix*"{
|
||||
$chassisType = "Anesthesia Cart"
|
||||
}
|
||||
|
||||
Default {$chassisType = "Unknown Model/Chassis"}
|
||||
}
|
||||
|
||||
Write-Progress -Activity "Retrieving data from online computers" -Status "$Env:COMPUTERNAME | Querying Spark!... Timeout 100s" -PercentComplete 90
|
||||
$uri = "${using:Tenant}/api/odata/businessobject/cis`?`$filter=Name eq '$ENV:COMPUTERNAME'&`$top=1&`$skip=0"
|
||||
try {
|
||||
$Query = Invoke-RestMethod -Method GET -uri $uri -headers ${using:Headers} -TimeoutSec 100
|
||||
} catch {
|
||||
Write-Host $_.Exception.Message
|
||||
}
|
||||
$cmdbData = $Query.Value
|
||||
|
||||
$LocationConstructors = @(
|
||||
"SHS_AssetLocality",
|
||||
"ivnt_Location",
|
||||
"SHS_Floor",
|
||||
"SHS_Department",
|
||||
"SHS_LocationDetails"
|
||||
)
|
||||
|
||||
$LocationData = Foreach($Loc in $LocationConstructors){
|
||||
|
||||
if ($Loc -eq 'SHS_Floor'){
|
||||
$(if ($cmdbData.$Loc -match '-'){$cmdbData.$Loc.split('-')[-1] + " Floor"} else{$cmdbData.$Loc})
|
||||
} elseif (![string]::IsNullOrEmpty($cmdbData.$Loc)){
|
||||
$cmdbData.$Loc
|
||||
}
|
||||
}
|
||||
|
||||
$LocationData = $LocationData -join ' | '
|
||||
|
||||
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 90
|
||||
#Output
|
||||
# $i++ | ProgressBar $i $comp 'Generating Output' $NumberofComputers $PCID
|
||||
$obj = New-Object -TypeName PSObject
|
||||
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'Hostname' -Value $Env:COMPUTERNAME
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'Status' -Value "Online"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'Current User' -Value "$userName"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'Last User(s)' -Value "$TotalLastUsers"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'IP | MAC' -Value "$ip | $mac"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'Adapter' -Value "$adapter"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'Model' -Value "$Model ($chassisType)"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'OS' -Value $os
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'OS Build' -Value $osBuild
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'BIOS Ver' -Value "$biosVersion"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'Encryption' -Value "$EncryptionStatus"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'Free Space' -Value "$freespace | $driveType"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'RAM' -Value "$ram"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'SSO Client' -Value "$imprivataType"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'Kiosk Role' -Value "$kioskRole"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'Citrix Ver' -Value "$citrixVersion"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'Asset Tag' -Value "$assetTag"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'Service Tag' -Value "$serviceTag"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'Last Reboot' -Value "$lastbootTime"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'TPM Status' -Value "$tpmStatus"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'MBAM GPO' -Value "$gpostatus"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'Printers' -Value "$printers"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'CMDB Location' -Value "$LocationData"
|
||||
if($cmdbData.SHS_IsException -eq 'True'){
|
||||
Write-host "***NOTICE: $ENV:COMPUTERNAME is a Device Exception computer. Please check CMDB/Asset Mgmt prior to supporting this workstation. ***" -BackgroundColor Black -ForegroundColor Yellow
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'DEL Owner' -Value $cmdbData.SHS_ExceptionContact
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'DEL Vendor PC' -Value $cmdbData.SHS_IsVendorPC
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'DEL Description' -Value $cmdbData.SHS_ExceptionNotes
|
||||
}
|
||||
|
||||
return $obj
|
||||
}
|
||||
#endregion
|
||||
$OnlineComputers = @()
|
||||
$OfflineComputers = @()
|
||||
$output = @()
|
||||
|
|
@ -384,7 +21,7 @@ function Get-PCBatchInvoke {
|
|||
}
|
||||
}
|
||||
BatchInvokesProgressBar -stage 2
|
||||
$invokeJob = Invoke-Command -ScriptBlock $sblock -ComputerName $OnlineComputers -SessionOption (New-PSSessionOption -NoMachineProfile -OpenTimeout 45000) -AsJob
|
||||
$invokeJob = Invoke-Command -ScriptBlock ${function:Get-PCLocal} -ComputerName $OnlineComputers -SessionOption (New-PSSessionOption -NoMachineProfile -OpenTimeout 45000) -AsJob
|
||||
$offlineJobs = @()
|
||||
if($OfflineComputers.count -gt 0){
|
||||
foreach($computer in $OfflineComputers){
|
||||
|
|
@ -418,32 +55,6 @@ function Get-PCBatchInvoke {
|
|||
|
||||
}
|
||||
|
||||
Function Get-CMDBLocation {
|
||||
[CmdletBinding()]
|
||||
param (
|
||||
[Parameter()]
|
||||
$cmdb
|
||||
)
|
||||
|
||||
if($null -eq $cmdb){
|
||||
$location = "*CMDB Mismatch - check CMDB*"
|
||||
return $location
|
||||
}
|
||||
|
||||
if($cmdb.values._SHSCalcLocationString.length -gt $cmdb.values._SHSLocation3.length){
|
||||
|
||||
$location = $cmdb.values._SHSCalcLocationString
|
||||
}
|
||||
else{
|
||||
$location = $cmdb.values._SHSLocation3
|
||||
}
|
||||
if($null -eq $location -or '' -eq $location){
|
||||
$location = "*No location data - Please update CMDB*"
|
||||
}
|
||||
|
||||
return $location
|
||||
}
|
||||
|
||||
function BatchInvokesProgressBar {
|
||||
param (
|
||||
$item,
|
||||
|
|
@ -453,8 +64,8 @@ function BatchInvokesProgressBar {
|
|||
)
|
||||
switch ($stage) {
|
||||
1 { Write-Progress -Activity "Connecting to computers" -Status "$item ($currentItemIndex/$TotalItems)" -PercentComplete (($currentItemIndex/$TotalItems) * 100)}
|
||||
2 { Write-Progress -Activity "Spinning up jobs" -PercentComplete ((20/100) * 100)}
|
||||
3 { Write-Progress -Activity "Awaiting Online Jobs" -PercentComplete ((60/100)*100)}
|
||||
2 { Write-Progress -Activity "Spinning up jobs" -PercentComplete ((10/100) * 100)}
|
||||
3 { Write-Progress -Activity "Querying online computers" -PercentComplete ((20/100)*100)}
|
||||
4 { Write-Progress -Activity "Querying SCCM for offline computers" -PercentComplete ((75/100) * 100)}
|
||||
5 { Write-Progress -Activity "Querying CMDB for computers not in SCCM" -PercentComplete ((75/100) * 100)}
|
||||
Default {}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ function Get-CMDBFallback {
|
|||
# }
|
||||
if($cmdbData.CIType -eq 'MobileDevice'){
|
||||
|
||||
$cmdbData = Get-ISMBO -bo ci__mobiledevicess -RecID $cmdbData.RecId
|
||||
$cmdbData = Get-ISMBO -bo ci__mobiledevices -RecID $cmdbData.RecId
|
||||
|
||||
# $props = [Ordered]@{
|
||||
# Hostname = $cmdbData.Title
|
||||
|
|
|
|||
|
|
@ -56,6 +56,15 @@ function Get-Hostname ([string]$name) {
|
|||
else { $errMsg += "CMDB name associated with Asset tag $name doesn't resolve to IP Address"}
|
||||
} else { $errMsg += "Asset tag not in CMDB" }
|
||||
}
|
||||
if ($name -match "^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$") {
|
||||
try {
|
||||
$cmdbData = Search-ISMBO -bo cis -Filter "MACAddress eq '$name'" -RawFilter
|
||||
} catch { $cmdbData = $null }
|
||||
if ( $cmdbData ) {
|
||||
if (Resolve-DnsName $cmdbData.Name) { return $cmdbData.Name,'' }
|
||||
else { $errMsg += "CMDB name associated with MAC Address $name doesn't resolve to IP Address"}
|
||||
} else { $errMsg += "MAC Address not in CMDB" }
|
||||
}
|
||||
# Serial number
|
||||
try {
|
||||
$cmdbData = Search-ISMBO -bo cis -Filter "SerialNumber eq '$name'" -RawFilter
|
||||
|
|
|
|||
|
|
@ -1,278 +1,216 @@
|
|||
function Get-PCLocal {
|
||||
param (
|
||||
[string]$comp,
|
||||
[int]$NumberofComputers,
|
||||
[int]$PCID
|
||||
)
|
||||
$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 "CPU Type" $NumberofComputers $PCID
|
||||
$compCPU = Get-CPUTypeLocal
|
||||
$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 "Chassis Type" $NumberofComputers $PCID
|
||||
$chassisType = Get-ChassisType $compCPU $compModel
|
||||
# Spark connection params
|
||||
$Tenant = 'https://samaritanhealth-amc.ivanticloud.com'
|
||||
$Headers = @{
|
||||
"Content-Type" = "application/json"
|
||||
"Authorization" = 'rest_api_key=EB68123D62F8489295C807353C92D75B'
|
||||
"Accept" = "*/*"
|
||||
"Accept-Encoding" = "gzip, deflate, br"
|
||||
}
|
||||
|
||||
$i++ | ProgressBar $i $comp " Local Last User" $NumberofComputers $PCID
|
||||
$lastUser = Get-LastLoginTimes
|
||||
$i++ | ProgressBar $i $comp "Local Imprivata" $NumberofComputers $PCID
|
||||
$imprivataType = Get-PCImprivataTypeLocal
|
||||
$i++ | ProgressBar $i $comp "Local Kiosk Role" $NumberofComputers $PCID
|
||||
$kioskRole = Get-PCKioskRoleLocal
|
||||
$i++ | ProgressBar $i $comp "Local Kiosk Type" $NumberofComputers $PCID
|
||||
$kioskType = Get-PCKioskTypeLocal
|
||||
$i++ | ProgressBar $i $comp "Local ReleaseID" $NumberofComputers $PCID
|
||||
$releaseID = PCReleaseIDLocal
|
||||
$i++ | ProgressBar $i $comp "Local Printers" $NumberofComputers $PCID
|
||||
$getPrinter = Get-PCPrinterLocal
|
||||
#$i++ | ProgressBar $i $comp "Time Stamp" $NumberofComputers $PCID
|
||||
#$lastUserTimeStamp = Get-PCLastUserTimestampLocal
|
||||
$i++ | ProgressBar $i $comp "GPO Status" $NumberofComputers $PCID
|
||||
$getGPOStatus = Get-GPOStatusLocal
|
||||
$i++ | ProgressBar $i $comp "TPM Status" $NumberofComputers $PCID
|
||||
$tpmStatus = Get-TPMStatusLocal
|
||||
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 10
|
||||
try {$win32_networkadapterconfiguration = Get-CimInstance -Class win32_networkadapterconfiguration} catch {$win32_networkadapterconfiguration = $null} #| MAC Address,
|
||||
try {$win32_LogicalDisk = Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DriveType=3" } catch {$win32_LogicalDisk = $null} #| Diskspace,
|
||||
try {$win32_SystemEnclosure = Get-CimInstance -ClassName Win32_SystemEnclosure} catch {$win32_SystemEnclosure = $null} #| Asset Tag
|
||||
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 20
|
||||
try {$bitlocker = manage-bde -status C:} catch {$bitlocker = $null} # | Bitlocker Status
|
||||
try {$PCInfo = get-computerinfo} catch {$PCInfo = $null}
|
||||
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 30
|
||||
try {$physicalDisk = Get-PhysicalDisk} catch {$physicalDisk = $null} # | Disk Type
|
||||
try {$win32_printer = (Get-CimInstance -ClassName win32_printer | Where-Object {$_.PortName -ne 'PORTPROMPT:' -and $_.PortName -ne 'nul:' -and $_.PortName -ne 'SHRFAX:'} | Select-Object -ExpandProperty Name) -join ' || ' }
|
||||
catch{ $win32_printer = $null} # | Printers
|
||||
try {$imprivataRegEntry = Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\SSOProvider\ISXAgent} catch {$imprivataRegEntry = $null}
|
||||
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 40
|
||||
try {$kioskRegEntry = Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\SHSCustom} catch {$kioskRegEntry = $null}
|
||||
try {$win32_tpm = Get-CimInstance -Namespace root\cimv2\security\microsofttpm -Class win32_tpm} catch{$win32_tpm = $null} # | TPM
|
||||
|
||||
<#
|
||||
$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"}
|
||||
}
|
||||
#>
|
||||
|
||||
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 50
|
||||
$CitrixViewer = "C:\Program Files (X86)\Citrix\ICA Client\CDViewer.exe"
|
||||
#$LastUser = Get-ChildItem -Path C:\Users -Directory -Force -Exclude Public,Default,'Default User','All Users' | Sort-Object -Property LastWriteTime -Descending | Select-Object -First 3 # | Last Users
|
||||
try {$CPU = (Get-CimInstance -ClassName Win32_processor ).Name } catch {$CPU = $null}
|
||||
|
||||
|
||||
#MAC Address
|
||||
$MAC = ($win32_networkadapterconfiguration | Where-Object {$_.IpEnabled -Match "True"} | Select-Object -Expand macaddress) -join ","
|
||||
|
||||
#IP
|
||||
$ip = ($win32_networkadapterconfiguration | Where-Object {$_.IpEnabled -Match "True"} | Select-Object -Expand IPAddress) -join ","
|
||||
<#
|
||||
if($ip -is [array]){
|
||||
$ip = $ip[0]
|
||||
}
|
||||
#>
|
||||
|
||||
#Adapter
|
||||
$adapter = ($win32_networkadapterconfiguration | Where-Object {$_.IpEnabled -Match "True"} | Select-Object -Expand Description) -join " | "
|
||||
<#
|
||||
if($adapter -is [array]){
|
||||
$adapter = $adapter[0]
|
||||
}
|
||||
#>
|
||||
|
||||
#UserName
|
||||
$Username = $PCInfo.CSUserName
|
||||
if($null -eq $Username){
|
||||
|
||||
$Username = (Invoke-Command -SessionOption (New-PSSessionOption -NoMachineProfile) -ScriptBlock {Get-Process Explorer -IncludeUsername | Where-Object { $_.Username -notlike "*SYSTEM" }} ).Username
|
||||
|
||||
if($null -ne $Username){
|
||||
$Username = "$Username (RDP/Inactive)"
|
||||
}
|
||||
else{
|
||||
$Username = '**None**'
|
||||
}
|
||||
}
|
||||
|
||||
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 60
|
||||
#Collecting most recent users from the registry
|
||||
$lastuser = @()
|
||||
$profiles = Get-CimInstance -Class Win32_UserProfile
|
||||
$profiles | Where-Object {$_.SID.length -gt 10} | Foreach-Object {
|
||||
|
||||
$sid = $_.SID
|
||||
$prop = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\$sid\"
|
||||
|
||||
if($prop.LocalProfileUnLoadTimeHigh -and $prop.LocalProfileUnLoadTimeLow){
|
||||
$a = '{0:x}' -f $prop.LocalProfileUnLoadTimeHigh
|
||||
$b = '{0:x}' -f $prop.LocalProfileUnLoadTimeLow
|
||||
$dec = [bigint]::Parse("$a$b",'AllowHexSpecifier')
|
||||
$time = w32tm /ntte $dec
|
||||
$lastTime = [datetime]($time -split ' - ')[1]
|
||||
}
|
||||
else{
|
||||
$lastTime = "Unknown"
|
||||
}
|
||||
|
||||
$obj = [PSCustomObject]@{
|
||||
Name = ($_.LocalPath -split 'C:\\Users\\')[1]
|
||||
LocalPath = $_.LocalPath
|
||||
LastLoginTime = $lastTime
|
||||
}
|
||||
$lastuser += $obj
|
||||
}
|
||||
|
||||
$lastuser = $lastuser | Where-Object LastLoginTime -ne 'Unknown' | Sort-Object LastLoginTime -Descending
|
||||
#Last User
|
||||
if($lastUser.Count -gt 1){
|
||||
|
||||
$lastUser1 = ($lastUser[0].Name + "-(" + $lastUser[0].LastLoginTime + ")").Split("-")
|
||||
$lastUser2 = ($lastUser[1].Name + "-(" + $lastUser[1].LastLoginTime + ")").Split("-")
|
||||
$lastUser3 = ($lastUser[2].Name + "-(" + $lastUser[2].LastLoginTime + ")").Split("-")
|
||||
$lastUser1 = ($lastUser[0].Name + " (" + $lastUser[0].LastLoginTime + ")")
|
||||
$lastUser2 = ($lastUser[1].Name + " (" + $lastUser[1].LastLoginTime + ")")
|
||||
$lastUser3 = ($lastUser[2].Name + " (" + $lastUser[2].LastLoginTime + ")")
|
||||
|
||||
$TotalLastUsers = "$lastUser1 $lastUser2 $lastUser3"
|
||||
|
||||
}else{
|
||||
|
||||
$TotalLastUsers = $lastuser.Name + "( " + $lastuser.LastLoginTime + " )"
|
||||
$TotalLastUsers = $lastUser.Name + " (" + $lastUser.LastLoginTime + ")"
|
||||
}
|
||||
if($compOSVersion -ne "Microsoft Windows 10 Enterprise"){
|
||||
#ComputerModel
|
||||
$Model = $PCInfo.CsModel
|
||||
|
||||
$driveType = "(Drive Type: Unavailable on Win 7)"
|
||||
}
|
||||
#RAM
|
||||
$totalram = $PCInfo.CsTotalPhysicalMemory
|
||||
$totalram = [math]::Round(($totalram / 1GB))
|
||||
$ram = "$totalram GB"
|
||||
|
||||
Switch($kioskType)
|
||||
{
|
||||
1 {}
|
||||
2 {$imprivataType = "Kiosk"}
|
||||
}
|
||||
#Drive Type
|
||||
$DriveType = $physicalDisk.MediaType
|
||||
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 70
|
||||
#Free Harddrive Space
|
||||
$CompFreeSpace = @([math]::Round($win32_LogicalDisk.FreeSpace / 1gb,2),[math]::Round($win32_LogicalDisk.Size / 1gb,2))
|
||||
$free = $compFreeSpace[0]
|
||||
$max = $compfreeSpace[1]
|
||||
$freespace = "$free GB / $max GB"
|
||||
|
||||
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"
|
||||
}
|
||||
#Service Tag
|
||||
#$serviceTag = $win32_bios.SerialNumber
|
||||
$serviceTag = $PCInfo.BiosSeralNumber
|
||||
#BIOS
|
||||
#$biosVersion = $win32_bios.SMBIOSBIOSVersion
|
||||
$biosVersion = $PCInfo.BiosName
|
||||
|
||||
if(!$userName)
|
||||
{
|
||||
$userName = "**None**"
|
||||
}
|
||||
#Last Reboot
|
||||
$lastbootTime = $PCInfo.OsLastBootUpTime
|
||||
|
||||
if(!$compAssetTag)
|
||||
{
|
||||
$compAssetTag = "(N/A in SMBios)"
|
||||
}
|
||||
|
||||
$compFreeSpaceGB = [math]::Round(($compFreeSpace[0] / 1GB),2)
|
||||
$compFreeSpaceMB = [math]::Round(($compFreeSpace / 1MB))
|
||||
$compMemory = [math]::Round(($compMemory / 1GB))
|
||||
|
||||
$compFreeSpaceMB = "$compFreeSpaceMB" + ' MB'
|
||||
$compFreeSpaceGB = "$compFreeSpaceGB" + ' GB'
|
||||
$compMemory = "$compMemory" + ' GB'
|
||||
|
||||
$locationData = Get-LocationDetails $comp
|
||||
|
||||
$i++ | ProgressBar $i $comp "Generating Output" $NumberofComputers $PCID
|
||||
|
||||
$props = [Ordered]@{
|
||||
Hostname = "$comp"
|
||||
Status = "Online"
|
||||
'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"
|
||||
'CMDB Location' = $locationData
|
||||
}
|
||||
|
||||
$obj = New-Object -TypeName PSObject -Property $props
|
||||
if ($locationData) {
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'CMDB Location' -Value $locationData
|
||||
}
|
||||
if ($delInfo) {
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'DEL Owner' -Value $delInfo.Contact
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'DEL Vendor PC' -Value $delInfo.Vendor
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'DEL Description' -Value $delInfo.Description
|
||||
}
|
||||
return $obj
|
||||
|
||||
}
|
||||
|
||||
#Region Local Only Helper Functions
|
||||
<# Function Get-PCLastUserLocal(){
|
||||
|
||||
$LastUser = 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-PCLastUserTimestampLocal(){
|
||||
|
||||
$LastUserTimeStamp = 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-PCImprivataTypeLocal(){
|
||||
|
||||
$ImprivataType = Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\SSOProvider\ISXAgent |
|
||||
Select-Object -ExpandProperty FUS_Enabled
|
||||
|
||||
Switch($ImprivataType)
|
||||
{
|
||||
0 {$ImprivataType = "SUD"}
|
||||
1 {$ImprivataType = "MUD"}
|
||||
Default {$ImprivataType = "Imprivata Agent not Installed"}
|
||||
}
|
||||
|
||||
Return $ImprivataType
|
||||
}
|
||||
|
||||
Function Get-PCKioskRoleLocal(){
|
||||
|
||||
$KioskRole = Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\SHSCustom | Select-Object -ExpandProperty KioskRole
|
||||
|
||||
Return $KioskRole
|
||||
}
|
||||
|
||||
Function Get-PCKioskTypeLocal(){
|
||||
|
||||
$KioskType = Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\SSOProvider\ISXAgent | Select-Object -ExpandProperty Type
|
||||
|
||||
Return $KioskType
|
||||
}
|
||||
|
||||
Function Get-PCReleaseIDLocal(){
|
||||
|
||||
$ReleaseID = (Get-Item "HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion").GetValue('ReleaseID')
|
||||
if($ReleaseID -gt 2004){
|
||||
$ReleaseID = (Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion").DisplayVersion
|
||||
}
|
||||
|
||||
Return $ReleaseID
|
||||
}
|
||||
|
||||
Function Get-PCHasBitLockerLocal(){
|
||||
|
||||
$bitlocker = manage-bde -status C:
|
||||
$PercentageEncrypted = ((manage-bde -status C: | Select-String "Percentage Encrypted") -split ': ')[1]
|
||||
#Asset Tag
|
||||
$assetTag = $win32_SystemEnclosure.SMBiosAssetTag
|
||||
|
||||
#Bitlocker Status
|
||||
$PercentageEncrypted = (($bitlocker | Select-String "Percentage Encrypted") -split ': ')[1]
|
||||
[int]$IntPercentageEncrypted = $PercentageEncrypted.Substring(0,4)
|
||||
|
||||
$EncryptionStatus = $null
|
||||
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-PCPrinterLocal(){
|
||||
#OS
|
||||
$os = $PCInfo.OSName + " (" + $PCInfo.OSArchitecture + ")"
|
||||
|
||||
$GetPrinter = (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
|
||||
#OS Build
|
||||
$osVer = $PCInfo.WindowsVersion
|
||||
if($osVer -gt 2004){
|
||||
$osVer = (Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion").DisplayVersion
|
||||
}
|
||||
$osBuild = $PCInfo.OSBuildNumber
|
||||
$osBuild = "Vers $osVer | Build #$osBuild"
|
||||
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 80
|
||||
#Printers
|
||||
$printers = $win32_printer# ($win32_printer | Where-Object {$_.PortName -ne 'PORTPROMPT:' -and $_.PortName -ne 'nul:' -and $_.PortName -ne 'SHRFAX:'} | Select-Object -ExpandProperty Name) -join ' || '
|
||||
if(!$printers){
|
||||
$printers = "No Local/Networked Printer (Check Printer Mappings)"
|
||||
}
|
||||
|
||||
Function Get-TPMStatusLocal(){
|
||||
#Imprivata
|
||||
$ImprivataType = $imprivataRegEntry | Select-Object -ExpandProperty Type
|
||||
if(!$imprivataType){
|
||||
$ImprivataType = "Not Installed"
|
||||
}
|
||||
else{
|
||||
Switch($ImprivataType){
|
||||
1 {
|
||||
$ImprivataType = $imprivataRegEntry | Select-Object -ExpandProperty FUS_Enabled
|
||||
Switch($ImprivataType){
|
||||
0 {$ImprivataType = "SUD"}
|
||||
1 {$ImprivataType = "MUD"}
|
||||
}
|
||||
}
|
||||
2 {$ImprivataType = "Kiosk"}
|
||||
Default {$ImprivataType = "Not Installed"}
|
||||
}
|
||||
}
|
||||
$kioskRole = try {$kioskRegEntry | Select-Object -ExpandProperty KioskRole} catch{ $null }
|
||||
if (!$kioskRole) { $kioskRole = "None"}
|
||||
|
||||
#TPM
|
||||
$win32_tpm = Get-CimInstance -Namespace root\cimv2\security\microsofttpm -Class win32_tpm
|
||||
if($win32_tpm){
|
||||
$tpmStatus = "On"
|
||||
$tpmVersion = " | Vers " + $win32_tpm.ManufacturerVersionFull20
|
||||
$tpmStatus = "On"
|
||||
if($win32_tpm.IsActivated_InitialValue){
|
||||
$tpmStatus += ", Activated"
|
||||
}
|
||||
|
|
@ -297,37 +235,137 @@ Function Get-TPMStatusLocal(){
|
|||
$tpmStatus = "Off"
|
||||
}
|
||||
|
||||
return $tpmStatus
|
||||
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 90
|
||||
#Citrix Version
|
||||
if( !(Test-path $CitrixViewer)){
|
||||
|
||||
$CitrixVersion = "Not Installed"
|
||||
}
|
||||
else{
|
||||
#Checks this default install path
|
||||
$CitrixVersion = Get-Command $citrixViewer | select-object -ExpandProperty Version #Grabs Citrix version number
|
||||
}
|
||||
|
||||
Function Get-GPOStatusLocal(){
|
||||
#Chassis Type
|
||||
|
||||
$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")
|
||||
Switch -Wildcard($Model) {
|
||||
"Optiplex*" {
|
||||
Switch -Wildcard($CPU)
|
||||
{
|
||||
$true {Return "GPO Applied"}
|
||||
$false {Return "GPO Not Applied"}
|
||||
Default {Return "Error...GPOTEST Line PCLocal Line 129"}
|
||||
"Intel(R) Core(TM) i5-9500 CPU*" {$chassisType = "SFF"} #5070
|
||||
|
||||
"Intel(R) Core(TM) i5-6500 CPU*" {$chassisType = "SFF"} #7040
|
||||
|
||||
"Intel(R) Core(TM) i5-6500T*" {$chassisType = "Micro"} #7040
|
||||
|
||||
"Intel(R) Core(TM) i7-6700 CPU*" {$chassisType = "SFF"} #7040
|
||||
|
||||
"Intel(R) Core(TM) i7-6700T*" {$chassisType = "Micro"} #7040
|
||||
|
||||
"Intel(R) Core(TM) i5-10500T*" {$chassisType = "Micro"} #5080
|
||||
|
||||
"Intel(R) Core(TM) i5-9500T*" {$chassisType = "Micro"} #5070
|
||||
|
||||
"Intel(R) Core(TM) i5-8500 CPU*" {$chassisType = "SFF"} #5060
|
||||
|
||||
"Intel(R) Core(TM) i5-8500T*" {$chassisType = "Micro"} #5060
|
||||
|
||||
"Intel(R) Core(TM) i5-7500*" {$chassisType = "SFF"} #5050
|
||||
|
||||
"Intel(R) Core(TM) i5-4670 CPU*" {$chassisType = "SFF"} #9020
|
||||
|
||||
"Intel(R) Core(TM) i5-4590 CPU*" {$chassisType = "SFF"} #9020
|
||||
|
||||
"Intel(R) Core(TM) i5-4590T CPU*" {$chassisType = "Micro"} #9020M
|
||||
|
||||
"Intel(R) Core(TM) i5-4690 CPU*" {$chassisType = "SFF"} #9020
|
||||
|
||||
"Intel(R) Core(TM) i5-3550 CPU*" {$chassisType = "SFF"} #9010
|
||||
|
||||
"Intel(R) Core(TM) i5-2400 CPU*" {$chassisType = "SFF"} #990
|
||||
|
||||
Default {$chassisType = "Optiplex - Chassis Type - Unknown"}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
"Latitude*" {
|
||||
$chassisType = "Laptop"
|
||||
}
|
||||
"Precision*"{
|
||||
$chassisType = "Laptop"
|
||||
}
|
||||
"M24*" {
|
||||
$chassisType = "Anesthesia Cart"
|
||||
}
|
||||
"Medix*"{
|
||||
$chassisType = "Anesthesia Cart"
|
||||
}
|
||||
|
||||
Default {$chassisType = "Unknown Model/Chassis"}
|
||||
}
|
||||
|
||||
$timeout = 10
|
||||
Write-Progress -Activity "Retrieving data from online computers" -Status "$Env:COMPUTERNAME | Querying Spark!... Timeout $($timeout)s" -PercentComplete 95
|
||||
$uri = "$Tenant/api/odata/businessobject/cis`?`$filter=Name eq '$ENV:COMPUTERNAME'&`$top=1&`$skip=0"
|
||||
try {
|
||||
$Query = Invoke-RestMethod -Method GET -uri $uri -headers $Headers -TimeoutSec $timeout
|
||||
} catch {
|
||||
Write-Host $_.Exception.Message
|
||||
}
|
||||
$cmdbData = $Query.Value
|
||||
|
||||
$LocationConstructors = @(
|
||||
"SHS_AssetLocality",
|
||||
"ivnt_Location",
|
||||
"SHS_Floor",
|
||||
"SHS_Department",
|
||||
"SHS_LocationDetails"
|
||||
)
|
||||
|
||||
$LocationData = Foreach($Loc in $LocationConstructors){
|
||||
|
||||
if ($Loc -eq 'SHS_Floor'){
|
||||
$(if ($cmdbData.$Loc -match '-'){$cmdbData.$Loc.split('-')[-1] + " Floor"} else{$cmdbData.$Loc})
|
||||
} elseif (![string]::IsNullOrEmpty($cmdbData.$Loc)){
|
||||
$cmdbData.$Loc
|
||||
}
|
||||
}
|
||||
|
||||
Function Get-CPUTypeLocal(){
|
||||
$LocationData = $LocationData -join ' | '
|
||||
|
||||
$CPU = (Get-CimInstance -ClassName Win32_processor).Name
|
||||
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 100
|
||||
#Output
|
||||
# $i++ | ProgressBar $i $comp 'Generating Output' $NumberofComputers $PCID
|
||||
$obj = New-Object -TypeName PSObject
|
||||
|
||||
Return $CPU
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'Hostname' -Value $Env:COMPUTERNAME
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'Status' -Value "Online"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'Current User' -Value "$userName"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'Last User(s)' -Value "$TotalLastUsers"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'IP | MAC' -Value "$ip | $mac"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'Adapter' -Value "$adapter"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'Model' -Value "$Model ($chassisType)"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'OS' -Value "$os | $osBuild"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'BIOS Ver' -Value "$biosVersion"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'Encryption' -Value "$EncryptionStatus"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'Free Space' -Value "$freespace | $driveType"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'RAM' -Value "$ram"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'SSO Client' -Value "$imprivataType"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'Kiosk Role' -Value "$kioskRole"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'Citrix Ver' -Value "$citrixVersion"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'Asset Tag' -Value "$assetTag"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'Service Tag' -Value "$serviceTag"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'Last Reboot' -Value "$lastbootTime"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'TPM Status' -Value "$tpmStatus"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'Printers' -Value "$printers"
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'CMDB Location' -Value "$LocationData"
|
||||
if($cmdbData.SHS_IsException -eq 'True'){
|
||||
Write-host "***NOTICE: $ENV:COMPUTERNAME is a Device Exception computer. Please check CMDB/Asset Mgmt prior to supporting this workstation. ***" -BackgroundColor Black -ForegroundColor Yellow
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'DEL Owner' -Value $cmdbData.SHS_ExceptionContact
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'DEL Vendor PC' -Value $cmdbData.SHS_IsVendorPC
|
||||
$obj | Add-Member -MemberType NoteProperty -Name 'DEL Description' -Value $cmdbData.SHS_ExceptionNotes
|
||||
}
|
||||
|
||||
Function Get-CompModelLocal(){
|
||||
|
||||
$CompModel = (Get-CimInstance -ClassName Win32_ComputerSystem).Model
|
||||
|
||||
Return $CompModel
|
||||
return $obj
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -358,9 +358,6 @@ Function Get-PC {
|
|||
|
||||
#grabs info on attached monitors and usb devices
|
||||
if ($Devices) {
|
||||
ProgressBar -CurrentPC $comp -NumberofComputers $NumberofComputers -Percent $PCID -CurrentLocationText 'Devices' -CurrentPCNumber $PCID
|
||||
$PCID++
|
||||
|
||||
if ($compStatus -ne 'Online') {
|
||||
Write-Warning "$comp is $compStatus skipping monitor query"
|
||||
}
|
||||
|
|
@ -647,7 +644,7 @@ Function Get-PC {
|
|||
}
|
||||
|
||||
#This is the get-pc of get-pc. It collects all the data from the computers and puts it in an array to be outputed
|
||||
$outPutArray += Get-PCBatchInvoke($getPCComputers)
|
||||
if ($getPCComputers) { $outPutArray += Get-PCBatchInvoke($getPCComputers) }
|
||||
|
||||
if ($Orion) {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,11 @@
|
|||
Patch:
|
||||
Patch: 2024-09-13
|
||||
-Fix Order of hostame resolution changed so it's more consistent with true hostname
|
||||
-Remove MBAM GPO from output
|
||||
-Refactor BatchInvokes uses Get-PCLocal so there is only one spot to update
|
||||
-Fix shortened Spark! timeout since Spark! typically won't succeed after 5 seconds
|
||||
-Fix bug when querying mobile devices
|
||||
|
||||
Patch: 2024-09-12
|
||||
-Fix Hostnames now check SCCM for a hostname match as a fallback
|
||||
-Fix Devices now reports correct ports on DELL P2422H monitor
|
||||
-Add DevicesUnplugged to report unplugged devices like scanners or printers
|
||||
|
|
|
|||
Loading…
Reference in a new issue