Get-PC/Private/PCLocal.ps1

342 lines
12 KiB
PowerShell
Raw Normal View History

2024-06-11 18:27:55 +00:00
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
$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
$chassisType = Get-ChassisType $compCPU $compModel
$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
$i++ | ProgressBar $i $comp "Checking Bitlocker" $NumberofComputers $PCID
$hasBitLocker = Get-PCHasBitLockerLocal
$i++ | ProgressBar $i $comp "ChassisType" $NumberofComputers $PCID
$chassisType = Get-ChassisType $compCPU $compModel
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("-")
$TotalLastUsers = "$lastUser1 $lastUser2 $lastUser3"
}else{
$TotalLastUsers = $lastuser.Name + "( " + $lastuser.LastLoginTime + " )"
}
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 / 1MB))
$compMemory = [math]::Round(($compMemory / 1GB))
$compFreeSpaceMB = "$compFreeSpaceMB" + ' MB'
$compFreeSpaceGB = "$compFreeSpaceGB" + ' GB'
$compMemory = "$compMemory" + ' GB'
2024-08-02 19:03:04 +00:00
if (Get-SparkEnabled) {
$cmdbData = Get-SparkCI $ENV:ComputerName
$locationData = $cmdbData.SHS_Floor + ' - ' + $cmdbData.SHS_Department + ' - ' + $cmdbData.SHS_LocationDetails
if($cmdbData.SHS_IsException -eq 'True'){
$delInfo = Get-CMDBDELInfo $cmdbData
}
}
2024-06-11 18:27:55 +00:00
$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"
}
$obj = New-Object -TypeName PSObject -Property $props
2024-08-02 19:03:04 +00:00
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
}
2024-06-11 18:27:55 +00:00
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]
[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-PCPrinterLocal(){
$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
}
Function Get-TPMStatusLocal(){
#TPM
$win32_tpm = Get-CimInstance -Namespace root\cimv2\security\microsofttpm -Class win32_tpm
if($win32_tpm){
$tpmStatus = "On"
$tpmVersion = " | Vers " + $win32_tpm.ManufacturerVersionFull20
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"
}
return $tpmStatus
}
Function Get-GPOStatusLocal(){
$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 {Return "GPO Applied"}
$false {Return "GPO Not Applied"}
Default {Return "Error...GPOTEST Line PCLocal Line 129"}
}
}
Function Get-CPUTypeLocal(){
$CPU = (Get-CimInstance -ClassName Win32_processor).Name
Return $CPU
}
Function Get-CompModelLocal(){
$CompModel = (Get-CimInstance -ClassName Win32_ComputerSystem).Model
Return $CompModel
}
#endregion