Init commit

This commit is contained in:
Zachary Gorman 2024-06-11 11:27:55 -07:00
commit 4a01da0e5d
57 changed files with 28589 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.vscode

BIN
Data/ExpectedApps.json Normal file

Binary file not shown.

BIN
Data/ExpectedApps.json.bak Normal file

Binary file not shown.

BIN
Data/ExpectedApps.txt Normal file

Binary file not shown.

View file

@ -0,0 +1,38 @@
# Syntax:
# vendor vendor_name
# device device_name <-- single tab
# interface interface_name <-- two tabs
#------SHS-Equipment---------------------------------------------#
# All SHS equipment must have the vendor_name preceded by [SHS]
# Please follow syntax marked above. Note 2 spaces between VID and vendor_name, and between PID and device_name
# interface and interface_name are not used by SHS get-pc script
0C27 [SHS]Imprivata
3BFA Badge Reader
0554 [SHS]Nuance
1001 PowerMic II - Dragon Mic
147E [SHS]AuthenTec
2016 Imprivata Fingerprint Reader
0403 [SHS]FTDI, Ltd
6001 Topaz Signature Pad
0801 [SHS]MagTek
3004 DynaPro Credit Card Reader
1DCC [SHS]Ambir Technology
4816 Ambir Scanner - DS687
04C5 [SHS]Fujitsu, Ltd
132E fi-7160
114f fi-6130
11f3 fi-6130Z
0B00 [SHS]Ingenico
0062 iSC250 Credit Card Reader
0081 Lane 5000 Credit Card Reader
05D5 [SHS]Seal Shield
0624 Washable Keyboard
0C2E [SHS]Honeywell
0901 Wired Barcode Scanner
0921 Wireless Barcode Scanner
05E0 [SHS]Zebra
1200 Barcode Scanner
#----------------------------------------------------------------#

21948
Data/USBIDs.txt Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,8 @@
{
"folders": [
{
"path": "."
}
],
"settings": {}
}

105
Get-PC.Format.ps1xml Normal file
View file

@ -0,0 +1,105 @@
<?xml version="1.0" encoding="utf-8" ?>
<Configuration>
<ViewDefinitions>
<View>
<Name>Default</Name>
<ViewSelectedBy>
<TypeName>GetPC.App</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
<TableColumnHeader>
</TableColumnHeader>
<TableColumnHeader>
</TableColumnHeader>
<TableColumnHeader>
<Width>10</Width>
</TableColumnHeader>
<TableColumnHeader>
<Width>15</Width>
</TableColumnHeader>
<TableColumnHeader>
<Width>15</Width>
</TableColumnHeader>
<TableColumnHeader>
<Width>15</Width>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<PropertyName>DisplayName</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Publisher</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Version</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>InstallDate</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Computer</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>x86/x64</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
<View>
<Name>Default</Name>
<ViewSelectedBy>
<TypeName>GetPC.Devices</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
<TableColumnHeader>
</TableColumnHeader>
<TableColumnHeader>
</TableColumnHeader>
<TableColumnHeader>
</TableColumnHeader>
<TableColumnHeader>
</TableColumnHeader>
<TableColumnHeader>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<PropertyName>Manufacturer</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Description</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>DeviceID\SerialNumber</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>AttachedComputer</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Type</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
</ViewDefinitions>
</Configuration>

126
Get-PC.psd1 Normal file
View file

@ -0,0 +1,126 @@
#
# Module manifest for module 'Get-PC'
#
# Generated by: Chuck Beddow
#
# Generated on: 2/13/2020
#
@{
# Script module or binary module file associated with this manifest.
RootModule = 'Get-PC.psm1'
# Version number of this module.
ModuleVersion = '0.3.12'
# Supported PSEditions
# CompatiblePSEditions = @()
# ID used to uniquely identify this module
GUID = 'b886c6d1-2ff5-4fbe-894c-a0a049538a3e'
# Author of this module
Author = 'Chuck Beddow'
# Company or vendor of this module
CompanyName = 'Samaritan Health Services'
# Copyright statement for this module
Copyright = '(c) 2019 Chuck Beddow. All rights reserved.'
# Description of the functionality provided by this module
# Description = ''
# Minimum version of the Windows PowerShell engine required by this module
# PowerShellVersion = ''
# Name of the Windows PowerShell host required by this module
# PowerShellHostName = ''
# Minimum version of the Windows PowerShell host required by this module
# PowerShellHostVersion = ''
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# DotNetFrameworkVersion = ''
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# CLRVersion = ''
# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''
# Modules that must be imported into the global environment prior to importing this module
# RequiredModules = @()
# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()
# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()
# Format files (.ps1xml) to be loaded when importing this module
FormatsToProcess = @('Get-PC.Format.ps1xml')
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = 'Get-PC'
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()
# Variables to export from this module
# VariablesToExport = @()
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = @()
# DSC resources to export from this module
# DscResourcesToExport = @()
# List of all modules packaged with this module
# ModuleList = @()
# List of all files packaged with this module
# FileList = @()
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{
PSData = @{
# Tags applied to this module. These help with module discovery in online galleries.
# Tags = @()
# A URL to the license for this module.
# LicenseUri = ''
# A URL to the main website for this project.
# ProjectUri = ''
# A URL to an icon representing this module.
# IconUri = ''
# ReleaseNotes of this module
# ReleaseNotes = ''
# External dependent modules of this module
# ExternalModuleDependencies = ''
} # End of PSData hashtable
} # End of PrivateData hashtable
# HelpInfo URI of this module
# HelpInfoURI = ''
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''
}

20
Get-PC.psm1 Normal file
View file

@ -0,0 +1,20 @@
$functionFolders = @('Public', 'Private', 'Classes')
ForEach ($folder in $functionFolders)
{
$folderPath = Join-Path -Path $PSScriptRoot -ChildPath $folder
If (Test-Path -Path $folderPath)
{
Write-Verbose -Message "Importing from $folder"
$functions = Get-ChildItem -Path $folderPath -Filter '*.ps1'
ForEach ($function in $functions)
{
if($folder -eq 'Public'){
Write-Verbose -Message " Importing $($function.BaseName)"
}
Write-Verbose -Message " Importing $($function.BaseName)"
. $($function.FullName)
}
}
}
$publicFunctions = (Get-ChildItem -Path "$PSScriptRoot\Public" -Filter '*.ps1').BaseName
Export-ModuleMember -Function $publicFunctions

26
HeaderExample Normal file
View file

@ -0,0 +1,26 @@
<#
Use this header template for future modules. Not all parameters are required, this is merely a guide.
#>
<#
.SYNOPSIS
A summary of how the script works and how to use it.
.DESCRIPTION
A long description of how the script works and how to use it.
.NOTES
Information about the environment, things to need to be consider and other information.
.COMPONENT
Information about PowerShell Modules to be required.
.LINK
Useful Link to ressources or others.
.Parameter ParameterName
Description for a parameter in param definition section. Each parameter requires a separate description. The name in the description and the parameter section must match.
.Example
This is where you would show the user how to use the module. iE: Module-Name <args>
#>

88
Private/AppDiff.ps1 Normal file
View file

@ -0,0 +1,88 @@
param (
$examplePC
)
function Get-AppDiff {
param(
[Parameter(Mandatory)]
$pc,
$TableView = $false
)
# Compares a pc's apps with a list of expected apps to see if the pc has any
# extra apps that we need to consider downloading
$apps = Get-Apps $pc
$apps = Remove-Version $apps
# Open example file
$lookupTablePath = Join-Path (get-item $PSScriptRoot).Parent.FullName 'Data\ExpectedApps.json'
$example = get-content $lookupTablePath | ConvertFrom-Json
$output = @()
# Finds each app that isn't in the example
foreach ( $app in $apps ) {
if (
# Apps that shouldn't be considered an "installed app"
(-not ($app.DisplayName -match "Citrix")) -and
(-not ($app.DisplayName -match "Microsoft Visual C\+\+")) -and
(-not ($app.DisplayName -match "RightFax")) -and
# This check is last for performance
(-not ( $example.DisplayName -contains $app.DisplayName ) )
)
{
$output += $app
}
}
if($TableView){
$output | Out-GridView -Title "Get-PC Apps - $ComputerName"
}
else{
Write-Output $output
}
}
# Function parses get-pc -apps output to extract just the name, not the
# version number or other unnecessary info
function Remove-Version {
param ( $apps )
$output = @()
foreach ($app in $apps ) {
if ($null -eq $app.DisplayName) { continue }
# Strip out the version details
# " - " might filter out too much, not sure
$separator = "`t"," ", " - "
$option = [System.StringSplitOptions]::RemoveEmptyEntries
$app.DisplayName = $app.DisplayName.Split($separator, $option)[0]
$output += $app
}
Write-Output $output
}
function Copy-FileNoDestruct ($srcpath, $dstpath) {
while ($true) {
if (Test-Path $dstpath) {
$dstpath += ".bak"
} else {
Copy-Item -Path $srcpath -Destination $dstpath
return
}
}
}
function Get-ExampleApps {
param( $examplePC )
$appsPath = (Join-Path (get-item $PSScriptRoot).Parent.FullName 'Private\Apps.ps1')
Import-Module -Force $appsPath
$apps = Get-Apps $examplePC
$apps = Remove-Version $apps
# Open example file
$lookupTablePath = Join-Path (get-item $PSScriptRoot).Parent.FullName 'Data\ExpectedApps.json'
Copy-FileNoDestruct $lookupTablePath $($lookupTablePath + ".bak")
Write-Host "Writing expected apps to" $lookupTablePath
$apps | ConvertTo-Json | Out-File $lookupTablePath
}
if ($examplePC) {
Get-ExampleApps $examplePC
}

72
Private/Apps.ps1 Normal file
View file

@ -0,0 +1,72 @@
Function Get-Apps($ComputerName, $TableView) {
$SCCMServer = "shscm01.int.samhealth.net"
$SCCMNameSpace = "root\sms\site_100"
$SCCMX64Query = "select SMS_G_System_ADD_REMOVE_PROGRAMS_64.DisplayName, SMS_G_System_ADD_REMOVE_PROGRAMS_64.Version, SMS_G_System_ADD_REMOVE_PROGRAMS_64.Publisher, SMS_G_System_ADD_REMOVE_PROGRAMS_64.InstallDate from SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS_64 on
SMS_G_System_ADD_REMOVE_PROGRAMS_64.ResourceId = SMS_R_System.ResourceId inner join SMS_G_System_SYSTEM on
SMS_G_System_SYSTEM.ResourceId = SMS_R_System.ResourceId where SMS_G_System_SYSTEM.Name = '$ComputerName'"
$SCCMX86Query = "select SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName, SMS_G_System_ADD_REMOVE_PROGRAMS.Version, SMS_G_System_ADD_REMOVE_PROGRAMS.Publisher, SMS_G_System_ADD_REMOVE_PROGRAMS.InstallDate from SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on
SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId inner join SMS_G_System_SYSTEM on
SMS_G_System_SYSTEM.ResourceID = SMS_R_System.ResourceId where SMS_G_System_SYSTEM.Name = '$ComputerName'"
$64apps = Get-WmiObject -namespace $SCCMNameSpace -DirectRead -computer $SCCMServer -query $SCCMX64Query |
Select-Object -Property DisplayName | Add-Member -NotePropertyName x86/x64 -NotePropertyValue 64 -PassThru | Sort-Object -Property DisplayName
$86apps = Get-WmiObject -namespace $SCCMNameSpace -DirectRead -computer $SCCMServer -query $SCCMX86Query |
Select-Object -Property DisplayName | Add-Member -NotePropertyName x86/x64 -NotePropertyValue 32 -PassThru | Sort-Object -Property DisplayName
#Checks if local computer
if ($comp -eq $env:COMPUTERNAME) {
$localapps = Get-Package -ProviderName Programs -IncludeWindowsInstaller |
Select-Object @{N='DisplayName';E={$_.Name}} |
Sort-Object -Property DisplayName
} else {
$localapps = Invoke-Command -ComputerName $ComputerName -SessionOption $(New-PSSessionOption -MaxConnectionRetryCount 1) -ScriptBlock {
Get-Package -ProviderName Programs -IncludeWindowsInstaller |
Select-Object @{N='DisplayName';E={$_.Name}} |
Sort-Object -Property DisplayName
}
}
$out = $86apps + $64apps
$apps = @()
foreach ($item in $out) {
$a = New-Object -TypeName PSCustomObject
$a.PSObject.TypeNames.Insert(0, 'GetPC.App')
Copy-Property -From $item -To $a
$apps += $a
}
# Blank entry for visual break
$a = [PSCustomObject]@{
DisplayName = ""
}
$a.PSObject.TypeNames.Insert(0, 'GetPC.App')
$apps += $a
# Grab apps that are only returned by local query
$localOnly = Compare-Object $localapps $out -Property DisplayName -PassThru | Where-Object {$_.SideIndicator -eq '<='}
foreach ($item in $localOnly) {
$a = New-Object -TypeName PSCustomObject
$a.PSObject.TypeNames.Insert(0, 'GetPC.App')
Copy-Property -From $item -To $a
$apps += $a
}
if ($TableView) {
$apps | Out-GridView -Title "Get-PC Apps - $ComputerName"
}
else {
Write-Output $apps
}
}
function Copy-Property ($From, $To) {
$properties = Get-Member -InputObject $From -MemberType NoteProperty
foreach ($p in $properties) {
$To | Add-Member -MemberType NoteProperty -Name $p.Name -Value $From.$($p.Name) -Force
}
}

View file

@ -0,0 +1,22 @@
Function Get-AssetConversion($ComputerName){
$SiteName="100"
$SCCMServer="shscm01.int.samhealth.net"
$SCCMNameSpace="root\sms\site_100"
#Set Asset Tag to $comp
$assetTagSCCM = $ComputerName
$SCCMQuery = "select SMS_R_System.Name from SMS_R_System inner join SMS_G_System_SYSTEM_ENCLOSURE on SMS_G_System_SYSTEM_ENCLOSURE.ResourceId = SMS_R_System.ResourceId Where SMS_G_System_SYSTEM_ENCLOSURE.SMBIOSAssetTag = '$assetTagSCCM'"
#Set $comp to find hostname of PC
$nameHolder = Get-WmiObject -namespace $SCCMNameSpace -DirectRead -computer $SCCMServer -query $SCCMQuery | Select-Object -First 1 -ExpandProperty Name
if($null -ne $nameHolder){
$ComputerName = $nameHolder
return $ComputerName
}
return $null
}

430
Private/BatchInvokes.ps1 Normal file
View file

@ -0,0 +1,430 @@
function Get-PCBatchInvoke {
[CmdletBinding()]
param (
[Parameter()]
[string[]]
$Computers
)
#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
try {$memoryAvailable = (Get-Counter '\Memory\Available Bytes').CounterSamples.CookedValue} catch {$memoryAvailable = $null}
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{$kioskRole = $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 -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"
return $obj
}
#endregion
$OnlineComputers = @()
$OfflineComputers = @()
$output = @()
$itemIndex = 0
foreach($comp in $Computers){
$itemIndex++
BatchInvokesProgressBar -item $comp -currentItemIndex $itemIndex -TotalItems $Computers.Count -stage 1
$Connection = Test-Connection -ComputerName $comp -Count 1
if($Connection){
$OnlineComputers += $comp
}
else{
$OfflineComputers += $comp
}
}
BatchInvokesProgressBar -stage 2
$output += Invoke-Command -ScriptBlock $sblock -ComputerName $OnlineComputers -SessionOption (New-PSSessionOption -NoMachineProfile -OpenTimeout 45000) | Select-Object * -ExcludeProperty RunspaceId, PSComputerName, PSShowComputerName
$itemIndex = 0
$contactedhosts = $output.Hostname
$missedhosts = $OnlineComputers | Where-Object -FilterScript {$_ -notin $contactedhosts}
$OfflineComputers += $missedhosts
foreach($computer in $output){
$itemIndex++
BatchInvokesProgressBar -item $computer.Hostname -currentItemIndex $itemIndex -TotalItems $output.Count -stage 3
$cmdbData = Get-CMDBData -comp $computer.Hostname -asset $computer.'Asset Tag'
$computer.'CMDB Location' = Get-CMDBLocation -cmdb $cmdbData
if($cmdbData.values.ConfigurationItem._SHSDELAsset -eq 'True'){
$delInfo = Get-CMDBDELInfo $cmdbData
$computer | Add-Member -MemberType NoteProperty -Name 'DEL Owner' -Value $delInfo.Owner
$computer | Add-Member -MemberType NoteProperty -Name 'DEL Vendor PC' -Value $delInfo.Vendor
$computer | Add-Member -MemberType NoteProperty -Name 'DEL Description' -Value $delInfo.Description
}
}
if($OfflineComputers.count -gt 0){
BatchInvokesProgressBar -stage 4
$itemIndex = 0
foreach($computer in $OfflineComputers){
$itemIndex++
$offlineCompData = Get-SCCMQuery -comp $computer -NumberofComputers $OfflineComputers.count -PCID $itemIndex
if($null -eq $offlineCompData.'Last Reboot'){
$offlineCompData = Get-CMDBFallback -comp $computer
}
$output += $offlineCompData
}
}
return $output
}
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,
$currentItemIndex,
$TotalItems,
$stage
)
switch ($stage) {
1 { Write-Progress -Activity "Connecting to computers" -Status "$item ($currentItemIndex/$TotalItems)" -PercentComplete (($currentItemIndex/$TotalItems) * 100)}
2 { Write-Progress -Activity "Retrieving data from online computers" -PercentComplete ((50/100) * 100)}
3 { Write-Progress -Activity "Grabbing CMDB Data" -Status "$item ($currentItemIndex/$TotalItems)" -PercentComplete (($currentItemIndex/$TotalItems) * 100)}
4 { Write-Progress -Activity "Querying SCCM for offline computers" -PercentComplete ((75/100) * 100)}
Default {}
}
}

76
Private/BatchJobs.ps1 Normal file
View file

@ -0,0 +1,76 @@
#Running batches as jobs
function Get-PCBatchJob{
[CmdletBinding()]
param (
$Computers,
[switch]$printers
)
$modulePath = (get-item $PSScriptRoot).Parent.FullName
$modulePath = "$modulePath\Get-PC.psd1"
$TotalItems = $Computers.count
$ActiveJobs = @()
$itemIndex = 0
foreach ($c in $computers){
if($printers){
JobsProgressBar $c $itemIndex $TotalItems 1
$ActiveJobs += Start-Job -Name $c -ArgumentList $c,$modulePath -ScriptBlock{
Import-Module $args[1] -WarningAction Ignore
get-pc $args[0] -SHSPrinter}
}
else{
JobsProgressBar $c $itemIndex $TotalItems 1
$ActiveJobs += Start-Job -Name $c -ArgumentList $c,$modulePath -ScriptBlock{
Import-Module $args[1] -WarningAction Ignore
get-pc $args[0]}
}
$itemIndex++
}
$completedJobs = @()
$itemIndex = 0
JobsProgressBar 'Waiting on jobs to be' $itemIndex $TotalItems 2
While(!$jobsDone){
$jobsDone = $true
foreach ($job in $ActiveJobs){
if($job.State -eq 'Running'){
$jobsDone = $false
}
if($job.State -eq 'Completed' -and !$completedJobs.Contains($job)){
$itemIndex++
JobsProgressBar $job.Name $itemIndex $TotalItems 2
$completedJobs += $job
}
}
Start-Sleep -Milliseconds 1
}
$itemIndex = 0
foreach($job in $completedJobs) {
$itemIndex++
JobsProgressBar $job.Name $itemIndex $TotalItems 3
$output = Receive-Job $job | Select-Object * -ExcludeProperty RunspaceId, PSComputerName, PSShowComputerName
Remove-job $job
Write-Output $output
}
}
function JobsProgressBar {
param (
$item,
$currentItemIndex,
$TotalItems,
$stage
)
switch ($stage) {
1 { Write-Progress -Activity "Starting Jobs" -Status "$item Job Started ($currentItemIndex/$TotalItems)" -PercentComplete (($currentItemIndex/$TotalItems) * 100)}
2 { Write-Progress -Activity "Jobs Running" -Status "$item Completed ($currentItemIndex/$TotalItems)" -PercentComplete (($currentItemIndex/$TotalItems) * 100)}
3 { Write-Progress -Activity "Retrieving Data" -Status "$item Completed ($currentItemIndex/$TotalItems)" -PercentComplete (($currentItemIndex/$TotalItems) * 100)}
Default {}
}
}

40
Private/Bypass.ps1 Normal file
View file

@ -0,0 +1,40 @@
Function Get-Bypass($ComputerName){
$BypassPath = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SMS\Client\Client Components\Remote Control"
$CommandStatus = $false
if(!(Test-Connection -ComputerName $ComputerName -Count 1))
{
Write-Host "Exiting bypass...No connection made to [$ComputerName]" -ForegroundColor Red
break
}
else
{
$CommandStatus = Invoke-Command -ComputerName $ComputerName -SessionOption (New-PSSessionOption -NoMachineProfile) -ScriptBlock {
if(Test-Path $Using:BypassPath)
{
Set-ItemProperty -Path $Using:BypassPath -Name "Permission Required" -Value 0
Return $true
}
else
{
Return $false
}
Return $false
}
if($CommandStatus)
{
Write-Host "Executed system bypass successfully on [$ComputerName] `nPath: $BypassPath" -ForegroundColor Green
}
else
{
Write-Host "Failed system bypass on [$ComputerName]`nPath: $BypassPath`nCheck [$ComputerName] is running Powershell V3.0 or above.`nCheck that registry exists." -ForegroundColor Red
}
}
Remove-PSSession $ComputerName
}

View file

@ -0,0 +1,37 @@
function Connect-LANDesk {
[CmdletBinding()]
param (
[Parameter(HelpMessage = 'The Server of landesk',
Mandatory = $false)]
[string]$server = "shsldapp1",
[Parameter(HelpMessage = 'The Framework',
Mandatory = $false)]
[string]$framework = "ServiceDeskAPI",
[Parameter(HelpMessage = 'The Framework',
Mandatory = $false)]
[string]$username = $env:username,
[Parameter(HelpMessage = 'The password used to connect',
Mandatory = $false)]
[String]$Pass = ''
)
if($env:username -like "jrodriguez.adm"){
$username = "jorodriguez"
}
elseif($env:username -like "*.adm"){
$username = $env:USERNAME.Split('.')[0]
}
else{
$username = "$env:username"
}
$pair = "$($username):$($Pass)"
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
$basicAuthValue = "Basic $encodedCreds"
$headers = @{}
$headers["Authorization"] = $basicAuthValue
$headers["Accept"] = "application/landesk.ldms.base+json,application/json"
$headers["Accept-Language"] = "en-US,en;q=0.8"
Return $headers, $server, $framework
}

34
Private/EventLog.ps1 Normal file
View file

@ -0,0 +1,34 @@
function Get-PCEventLog {
param (
[parameter(ValueFromPipeline)]
[string]$cn
)
if(!(Test-Connection -ComputerName $cn -Count 1)){
Write-Warning "$cn is unreachable"
return
}
$day = Read-Host "Number of days back (max 10)"
if($day -in 1..10){
$days = (Get-Date) - (New-TimeSpan -Day $day)
}
else {
Write-Warning "Days out of range: Defaulting to 10"
$days = (Get-Date) - (New-TimeSpan -Day 11)
}
$outputTitle = "$cn | System Error Logs | Last $Day Days"
$events = @()
$events += Get-WinEvent -ComputerName $cn -FilterHashtable @{ LogName='System'; Level=1; StartTime=$days }
$events += Get-WinEvent -ComputerName $cn -FilterHashtable @{ LogName='System'; Level=2; StartTime=$days }
$events += Get-WinEvent -ComputerName $cn -FilterHashtable @{ LogName='System'; Level=3; StartTime=$days }
$events | Out-GridView -Title $outputTitle
return
}

View file

@ -0,0 +1,9 @@
function ExportToExcel{
param (
$GetPCArray
)
$timestamp = get-date -Format "MMddhhmmssms"
$outfile = "$env:TMP\getpcoutput$timestamp.csv"
$GetPCArray | Export-Csv $outfile -NoTypeInformation
Invoke-Item $outfile
}

14
Private/FileSystem.ps1 Normal file
View file

@ -0,0 +1,14 @@
Function Get-FileSystem($ComputerName){
#Checks if the path is accessible to the requested PC
if(Test-Path \\$ComputerName\C$){
Test-Path -Path (ii \\$ComputerName\C$)
Write-Host "Accessing -FileSystem [\\$ComputerName\C$]" -ForeGround Green
}else{
Write-Host "Could not connect to -FileSystem [\\$ComputerName\C$]" -ForeGround Red
}
}

29
Private/GPUpdate.ps1 Normal file
View file

@ -0,0 +1,29 @@
Function Get-GPUpdate($ComputerName){
Write-Host "GPUPDATE on $ComputerName" -ForeGround Green
#Looks on the machine and tries to access the group policy.
try {
$oldPolicy = Get-ChildItem \\$ComputerName\c$\Windows\System32\GroupPolicy\Machine
}
catch{
Write-Host "Failed to access group policy" -ForegroundColor Red
return
}
#Deletes the old group policy. Reasoning is that if we are running this there is something very wrong and we will be immediately re-applying it.
if(!$oldPolicy){
Write-Host "No group policy found on machine" -ForegroundColor Red
}
else{
Remove-Item $oldPolicy
}
#Attempts to remotely re-apply group policy. If this fails I let the user know so they can go to the computer and manually do it.
try {
Invoke-Command -ComputerName $ComputerName -ScriptBlock {& gpupdate /force}
}
catch{
Write-Host "Unable to reapply group policy" -ForegroundColor Red
return
}
Write-Host 'GPUpdate Finished' -ForegroundColor Green
}

View file

@ -0,0 +1,24 @@
function Get-CMDBDELInfo {
param (
$cmdb
)
Write-host "***NOTICE: $comp is a Device Exception computer. Please check CMDB/Asset Mgmt prior to supporting this workstation. ***" -BackgroundColor Black -ForegroundColor Yellow
if($null -eq $cmdb){
return
}
if($cmdb.values.ConfigurationItem._SHSVendorPC -eq 'True'){
$vendor = "Yes | Non-standard SHS Image/Hardware"
}
else{
$vendor = "No | Standard SHS Hardware"
}
$delInfo = [PSCustomObject]@{
Owner = $cmdb.values.ConfigurationItem._SHSAssetOwner
Vendor = $vendor
Description = $cmdb.values.ConfigurationItem._Description
}
return $delInfo
}

View file

@ -0,0 +1,88 @@
function Get-CMDBFallback {
param (
$comp
)
$cmdbData = Get-LANDeskCMDBItem -name $comp
if(!$cmdbData){
if($comp.Length -gt 5){
$asset = $comp[-5..-1] -join ""
$cmdbData = Get-LANDeskCMDBItem -AssetTag $asset
if($cmdbData){
$comp = $cmdbData.values.Title
if(Test-Connection $comp){
$getpcData = get-pc $comp
return $getpcData
}
}
}
}
$status = $cmdbData.values.Status
if(!$status){
$status = 'No CMDB/SCCM Record Located'
}
else{
$status = $cmdbData.values.Status + ' (CMDB Data)'
}
if($cmdbData.values._SHSLocation3.Length -gt $cmdbData.values._SHSCalcLocationString.Length){
$locationData = $cmdbData.values._SHSLocation3
}
else{
$locationData = $cmdbData.values._SHSCalcLocationString
}
if($cmdbData.values._ConfigTypesCategory -eq 'Mobile Device'){
$props = [Ordered]@{
Hostname = $cmdbData.values.Title
'MAC' = $cmdbData.values._SHSMACAddress
Model = $cmdbData.values._Model + ' (' + $cmdbData.Values._SHSChasisRef + ')'
'OS' = $cmdbData.Values._SHSOperatingSystem
'Asset Tag' = $cmdbData.values._SHSAssetTag
'Service Tag' = $cmdbData.values._SerialNumber
'MDM Platform' = $cmdbData.values._SHSMDMPlatform
'Phone Number' = $cmdbData.values._SHSPhoneNumber
'Cellular Carrier' = $cmdbData.values._SHSCellularCarrier
'Cellular Voice' = $cmdbData.values._SHSCellularVoice
'Cellular Data' = $cmdbData.values._SHSCellularData
'CMDB Location' = $locationData
}
$obj = New-Object -TypeName PSObject -Property $props
}
else{
$props = [Ordered]@{
Hostname = "$comp"
Status = $status
'Current User' = "Not Available"
'Last User(s)' = $null
'IP | MAC' = $cmdbData.values._IPAddress + " | " + $cmdbData.values._SHSMACAddress
Model = $cmdbData.values._Model + ' (' + $cmdbData.Values._SHSChasisRef + ')'
'OS' = $cmdbData.Values._SHSOperatingSystem
'OS Build' = $null
'BIOS Ver' = $null
Encryption = $null
'Free Space' = $cmdbData.Values._AvailableDiskSpace + ' GB / ' + $cmdbData.Values._HardDiskSize + ' GB'
RAM = $cmdbData.Values._RAM + " GB "
'SSO Client' = "Not Available"
'Kiosk Role' = "Not Available"
'Asset Tag' = $cmdbData.values._SHSAssetTag
'Service Tag' = $cmdbData.values._SerialNumber
'Last Reboot' = $null
Printers = $null
'CMDB Location' = $locationData
}
$obj = New-Object -TypeName PSObject -Property $props
}
Write-Host "`n`nPulling cached CMDB data for $comp." -ForegroundColor Yellow
Write-Host "Last CMDB Update: ",$cmdbData.values.LastUpdate -ForegroundColor Yellow
if($cmdbData.values.ConfigurationItem._SHSDELAsset -eq 'True'){
$delInfo = Get-CMDBDELInfo $cmdbData
$obj | Add-Member -MemberType NoteProperty -Name 'DEL Owner' -Value $delInfo.Owner
$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
}

383
Private/Get-Devices.ps1 Normal file
View file

@ -0,0 +1,383 @@
function Get-Devices {
param (
[string]$comp
)
try {
$usb = Get-WmiObject Win32_USBControllerDevice -ComputerName $comp | ForEach-Object {[wmi]($_.Dependent)} | Sort-Object Manufacturer,Description,DeviceID | Select-Object Manufacturer,Description,@{N="DeviceID\SerialNumber";E={$_.DeviceID}}
$usb | Add-Member -NotePropertyName Type -NotePropertyValue USB
$usb | Add-Member -NotePropertyName AttachedComputer -NotePropertyValue $comp
foreach($item in $usb){
$friendlyNames = FindUSBDevice -deviceID $item.'DeviceID\SerialNumber'.ToString()
if($friendlyNames){
$item.Manufacturer = $friendlyNames[0]
if($item.Manufacturer.Length -le 5){
continue
}
if($item.Manufacturer.Substring(0,5) -eq '[SHS]'){
$item.Type = 'SHS Issued USB'
$len = $item.Manufacturer.Length -1
$item.Manufacturer = $item.Manufacturer[5..$len] -join ''
}
if($friendlyNames[1]){
$item.Description = $friendlyNames[1]
}
}
}
$usb = $usb | Sort-Object Manufacturer,Description
for ($i = 0; $i -lt $usb.Count - 1; $i++) {
if($usb[$i].Manufacturer -eq $usb[$i+1].Manufacturer -and $usb[$i].Description -eq $usb[$i+1].Description){
$usb[$i].Manufacturer = '__DUPE__'
}
}
$usb = $usb | Where-Object -Property Manufacturer -NE '__DUPE__'
$usb = $usb | Sort-Object Type
}
catch{
Write-warning 'Unable to grab USB info'
$usb = $null
}
$monitors = @()
$monitors += Get-Monitor $comp | Select-Object Manufacturer,@{N='Description';E={$_.Model}},@{N="DeviceID\SerialNumber";E={$_.SerialNumber}},AttachedComputer,ActivePort
$monitors | Add-Member -NotePropertyName Type -NotePropertyValue Monitor
$PortsHash = @{
'DELL P170S'= @('DVI','VGA');
'DELL P2317H'= @('DP','HDMI','VGA');
'DELL P2314H'= @('DP','DVI','VGA');
'DELL P2312H'= @('DVI','VGA');
'DELL P2319H'= @('DP','HDMI','VGA');
'DELL P2422H'= @('DP','VGA');
'DELL P2412H'= @('DP','VGA','HDMI');
}
foreach($item in $monitors){
$portList = ''
$found = $false
foreach ($port in $PortsHash.($item.Description)) {
if ($port -eq $item.ActivePort) { $portList += '*'; $found = $true }
$portList += $port + ','
}
$portList = $portList -replace "\,$"
$item.Description = $item.Description + ' (' + $portList + ')'
if ($found -ne $true) { $item.Description += " *" + $item.ActivePort }
}
$out = @()
foreach($item in ($monitors + $usb)){
$item.PSObject.TypeNames.Insert(0,'GetPC.Devices')
$out += $item
}
Write-Output $out
}
Function Get-Monitor {
<#
.SYNOPSIS
This powershell function gets information about the monitors attached to any computer. It uses EDID information provided by WMI. If this value is not specified it pulls the monitors of the computer that the script is being run on.
.DESCRIPTION
The function begins by looping through each computer specified. For each computer it gets a litst of monitors.
It then gets all of the necessary data from each monitor object and converts and cleans the data and places it in a custom PSObject. It then adds
the data to an array. At the end the array is displayed.
.PARAMETER ComputerName
Use this to specify the computer(s) which you'd like to retrieve information about monitors from.
.EXAMPLE
PS C:/> Get-Monitor.ps1 -ComputerName SSL1-F1102-1G2Z
Manufacturer Model SerialNumber AttachedComputer
------------ ----- ------------ ----------------
HP HP E241i CN12345678 SSL1-F1102-1G2Z
HP HP E241i CN91234567 SSL1-F1102-1G2Z
HP HP E241i CN89123456 SSL1-F1102-1G2Z
.EXAMPLE
PS C:/> $Computers = @("SSL7-F108F-9D4Z","SSL1-F1102-1G2Z","SSA7-F1071-0T7F")
PS C:/> Get-Monitor.ps1 -ComputerName $Computers
Manufacturer Model SerialNumber AttachedComputer
------------ ----- ------------ ----------------
HP HP LA2405x CN12345678 SSL7-F108F-9D4Z
HP HP E241i CN91234567 SSL1-F1102-1G2Z
HP HP E241i CN89123456 SSL1-F1102-1G2Z
HP HP E241i CN78912345 SSL1-F1102-1G2Z
HP HP ZR22w CN67891234 SSA7-F1071-0T7F
.NOTES
This script was written by MaxAnderson95 https://github.com/MaxAnderson95/Get-Monitor-Information/blob/master/Get-Monitor.psm1
#>
[CmdletBinding()]
PARAM (
[Parameter(ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)]
[String[]]$ComputerName = $env:ComputerName
)
#List of Manufacture Codes that could be pulled from WMI and their respective full names. Used for translating later down.
$ManufacturerHash = @{
"AAC" = "AcerView";
"ACR" = "Acer";
"AOC" = "AOC";
"AIC" = "AG Neovo";
"APP" = "Apple Computer";
"AST" = "AST Research";
"AUO" = "Asus";
"BNQ" = "BenQ";
"CMO" = "Acer";
"CPL" = "Compal";
"CPQ" = "Compaq";
"CPT" = "Chunghwa Pciture Tubes, Ltd.";
"CTX" = "CTX";
"DEC" = "DEC";
"DEL" = "Dell";
"DPC" = "Delta";
"DWE" = "Daewoo";
"EIZ" = "EIZO";
"ELS" = "ELSA";
"ENC" = "EIZO";
"EPI" = "Envision";
"FCM" = "Funai";
"FUJ" = "Fujitsu";
"FUS" = "Fujitsu-Siemens";
"GSM" = "LG Electronics";
"GWY" = "Gateway 2000";
"HEI" = "Hyundai";
"HIT" = "Hyundai";
"HSL" = "Hansol";
"HTC" = "Hitachi/Nissei";
"HWP" = "HP";
"IBM" = "IBM";
"ICL" = "Fujitsu ICL";
"IVM" = "Iiyama";
"KDS" = "Korea Data Systems";
"LEN" = "Lenovo";
"LGD" = "Asus";
"LPL" = "Fujitsu";
"MAX" = "Belinea";
"MEI" = "Panasonic";
"MEL" = "Mitsubishi Electronics";
"MS_" = "Panasonic";
"NAN" = "Nanao";
"NEC" = "NEC";
"NOK" = "Nokia Data";
"NVD" = "Fujitsu";
"OPT" = "Optoma";
"PHL" = "Philips";
"REL" = "Relisys";
"SAN" = "Samsung";
"SAM" = "Samsung";
"SBI" = "Smarttech";
"SGI" = "SGI";
"SNY" = "Sony";
"SRC" = "Shamrock";
"SUN" = "Sun Microsystems";
"SEC" = "Hewlett-Packard";
"TAT" = "Tatung";
"TOS" = "Toshiba";
"TSB" = "Toshiba";
"VSC" = "ViewSonic";
"ZCM" = "Zenith";
"UNK" = "Unknown";
"_YV" = "Fujitsu";
}
$ActivePortHash = @{
'0' = 'VGA';
'4' = 'DVI';
'5' = 'HDMI';
'10' = 'DP';
};
#Takes each computer specified and runs the following code:
ForEach ($Computer in $ComputerName) {
#Grabs the Monitor objects from WMI
$Monitors = Get-WmiObject -Namespace "root\WMI" -Class "WMIMonitorID" -ComputerName $Computer -ErrorAction SilentlyContinue
#Grabs data about the port driving the monitors
$activePortsData = get-ciminstance -namespace root/wmi -classname WmiMonitorConnectionParams -ComputerName $Computer -ErrorAction SilentlyContinue
#Transforms results of $activePortsData into a lookup table
$activePorts = @{}
foreach ($data in $activePortsData) {
#Translates port numeric code to a readable port identifier
$activePorts[ $data.InstanceName ] = $ActivePortHash["$($data.VideoOutputTechnology)"]
#Uses the raw code if the code isn't recognized (it's a really weird one)
if ($activePorts[ $data.InstanceName ] -eq $null) {
$activePorts[ $data.InstanceName ] = $data.VideoOutputTechnology
}
}
#Creates an empty array to hold the data
$Monitor_Array = @()
#Takes each monitor object found and runs the following code:
ForEach ($Monitor in $Monitors) {
#Grabs respective data and converts it from ASCII encoding and removes any trailing ASCII null values
If ([System.Text.Encoding]::ASCII.GetString($Monitor.UserFriendlyName) -ne $null) {
$Mon_Model = ([System.Text.Encoding]::ASCII.GetString($Monitor.UserFriendlyName)).Replace("$([char]0x0000)","")
} else {
$Mon_Model = $null
}
$Mon_Serial_Number = ([System.Text.Encoding]::ASCII.GetString($Monitor.SerialNumberID)).Replace("$([char]0x0000)","")
$Mon_Attached_Computer = ($Monitor.PSComputerName).Replace("$([char]0x0000)","")
$Mon_Manufacturer = ([System.Text.Encoding]::ASCII.GetString($Monitor.ManufacturerName)).Replace("$([char]0x0000)","")
#Filters out "non monitors". Place any of your own filters here. These two are all-in-one computers with built in displays. I don't need the info from these.
If ($Mon_Model -like "*800 AIO*" -or $Mon_Model -like "*8300 AiO*") {Break}
#Sets a friendly name based on the hash table above. If no entry found sets it to the original 3 character code
$Mon_Manufacturer_Friendly = $ManufacturerHash.$Mon_Manufacturer
If ($Mon_Manufacturer_Friendly -eq $null) {
$Mon_Manufacturer_Friendly = $Mon_Manufacturer
}
$Mon_Active_Port = $activePorts[ $Monitor.InstanceName ]
#Creates a custom monitor object and fills it with 4 NoteProperty members and the respective data
$Monitor_Obj = [PSCustomObject]@{
Manufacturer = $Mon_Manufacturer_Friendly
Model = $Mon_Model
SerialNumber = $Mon_Serial_Number
AttachedComputer = $Mon_Attached_Computer
ActivePort = $Mon_Active_Port
}
#Appends the object to the array
$Monitor_Array += $Monitor_Obj
} #End ForEach Monitor
#Outputs the Array
$Monitor_Array
} #End ForEach Computer
}
function Get-VIDPID {
param (
$deviceID
)
if($deviceID){
$bool = $deviceID -match '(?<=VID_)(....)'
if(!$bool){
return $null
}
$vid = $Matches[0]
$deviceID -match '(?<=PID_)(....)' | Out-Null
$p = $Matches[0]
return ($vid,$p)
}
else{
return $null
}
}
function FindUSBDevice {
param (
[string]$vid,
[string]$p,
[string]$deviceID
)
if($deviceID){
$bool = $deviceID -match '(?<=VID_)(....)'
if(!$bool){
return $null
}
$vid = $Matches[0]
$deviceID -match '(?<=PID_)(....)' | Out-Null
$p = $Matches[0]
}
$SHSEquip = MatchSHSEquipment $vid $p
if($SHSEquip){
return ($SHSEquip[0],$SHSEquip[1])
}
$lookupTablePath = Join-Path (get-item $PSScriptRoot).Parent.FullName 'Data\USBIDs.txt'
$usbIDs = Get-Content $lookupTablePath
for ($i = 0; $i -lt $usbIDs.Count; $i++) {
if ($usbIDs[$i] -match $vid){
if($usbIDs[$i][0] -eq "`t"){
}
else{
$man = ($usbIDs[$i] -split ' ')
$man = $man[2..$man.count] -join ' '
for ($y = $i+1; $y -lt $usbIDs.Count; $y++) {
if($usbIDs[$y][0] -ne "`t"){
return ($man,$null)
}
if($usbIDs[$y] -match $p){
$dev = ($usbIDs[$y] -split ' ')
$dev = $dev[2..$dev.count] -join ' '
return ($man,$dev)
}
}
return ($man,$null)
}
}
}
}
function MatchSHSEquipment {
param (
$vid,
$p
)
$lookupTablePath = Join-Path (get-item $PSScriptRoot).Parent.FullName 'Data\SHSEquipmentLookup.txt'
$usbIDs = Get-Content $lookupTablePath
for ($i = 0; $i -lt $usbIDs.Count; $i++) {
if ($usbIDs[$i] -match $vid){
if($usbIDs[$i][0] -eq "`t"){
}
else{
$man = ($usbIDs[$i] -split ' ')
$man = $man[2..$man.count] -join ' '
for ($y = $i; $y -lt $usbIDs.Count; $y++) {
if($usbIDs[$y] -match $p){
$dev = ($usbIDs[$y] -split ' ')
$dev = $dev[2..$dev.count] -join ' '
return ($man,$dev)
}
}
return $null
}
}
}
return $null
}

View file

@ -0,0 +1,47 @@
function Get-FreeDiskSpace {
param (
[array]$Computers
)
$sblock = {
#Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 80
try {$win32_LogicalDisk = Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DriveType=3" } catch {$win32_LogicalDisk = $null} #| Diskspace
$CompFreeSpace = @([math]::Round($win32_LogicalDisk.FreeSpace / 1gb,2),[math]::Round($win32_LogicalDisk.Size / 1gb,2))
$free = $compFreeSpace[0]
$max = $compfreeSpace[1]
$obj = New-Object -TypeName PSObject
$obj | Add-Member -MemberType NoteProperty -Name 'Hostname' -Value $Env:COMPUTERNAME
$obj | Add-Member -MemberType NoteProperty -Name 'Free Space' -Value $free
$obj | Add-Member -MemberType NoteProperty -Name 'Total Space' -Value $max
return $obj
}
$data = @()
$OnlineComputers = @()
$OfflineComputers = @()
$itemIndex = 0
foreach($comp in $Computers){
$itemIndex++
Write-Progress -Activity "Connecting to Computers" -Status $Env:COMPUTERNAME -PercentComplete ($itemIndex / $Computers.Count)*100
$Connection = Test-Connection -ComputerName $comp -Count 1
if($Connection){
$OnlineComputers += $comp
}
else{
$OfflineComputers += $comp
}
}
$data += Invoke-Command -ScriptBlock $sblock -ComputerName $OnlineComputers -SessionOption (New-PSSessionOption -NoMachineProfile -OpenTimeout 45000) | Select-Object * -ExcludeProperty RunspaceId, PSComputerName, PSShowComputerName
foreach($comp in $OfflineComputers){
$obj = New-Object -TypeName PSObject
$obj | Add-Member -MemberType NoteProperty -Name 'Hostname' -Value $comp
$obj | Add-Member -MemberType NoteProperty -Name 'Free Space' -Value 'OFFLINE'
$obj | Add-Member -MemberType NoteProperty -Name 'Total Space' -Value 'OFFLINE'
$data += $obj
}
return $data
}

View file

@ -0,0 +1,103 @@
function Get-LANDeskCMDBItem {
[CmdletBinding(DefaultParameterSetName="Default")]
param (
[Parameter(HelpMessage = 'Search LANDesk CMDB by the Name of the CMDM Item',
ParameterSetName = 'Title',
Mandatory = $true
)]
[string]$Name,
[Parameter(HelpMessage = 'Search LANDesk CMDB by the Configuration Item Type',
ParameterSetName = '_ConfigTypesCategory',
Mandatory = $true
)]
[string]$CIType,
[Parameter(HelpMessage = 'Search for the CMDB Item by Asset Tag Number',
ParameterSetName = '_SHSAssetTag',
Mandatory = $true
)]
[string]$AssetTag,
[Parameter(HelpMessage = 'Search for the Request by Current Assigned Group in LANDesk',
ParameterSetName = 'Default',
Mandatory = $false,
DontShow = $true
)]
[switch]$All,
[Parameter(HelpMessage = 'Specifying Server',
Mandatory = $false,
DontShow = $true)]
[string] $server = $(Connect-LANDesk)[1],
[Parameter(HelpMessage = 'Specifying LanDesk Framework for api',
Mandatory = $false,
DontShow = $true)]
[string] $framework = $(Connect-LANDesk)[2],
[Parameter(HelpMessage = 'Specifying LanDesk Headers for api',
Mandatory = $false,
DontShow = $true)]
[hashtable] $Headers = $(Connect-LANDesk)[0]
)
begin {
}
process {
$uri = 'http://' + $server + '/' + $framework + '/api/'
#$SearchURI = $uri + 'query/?class_name=_CMDBManagement.Call&page_size=20000000&attributes=Title,_ConfigTypesCategory,Status,_SHSDeleted,_SHSDeployedTo,_SHSCIPrimaryOwner,_PO,_SHSAssetTag,_CILocation,_RequestID,_IPAddress,_SerialNumber,_Department,_Model,_Manufacture,_SHSTier,_SHSAssetOwner,_SHSLocation3,_SHSWarrantyExpires,_SHSPOANumber,_SHSEpicPrinterWorkflow,_SHSLastAuditDate,_SHSEnvironment,Description,_IncidentQueue,_RequestQueue,_SHSCINotes,CreationDate,CreationUser,LastUpdate,LastUpdateUser,_SHSOperatingSystem,_SHSChassisType,_HardDiskSize,_RAM,_AvailableDiskSpace,_Model,_SHSKioskRoleName,_SerialNumber,_IPAddress,_SHSOSPatching,_SHSPatchSchedule,_SHSPatchNotes,_SHSDeviceExceptionContact,_SHSDeviceExceptionContact,_DisplayName&V=*'
$SearchURI = $uri + 'query/?class_name=_CMDBManagement.Call&page_size=20000000&attributes=Title,_ConfigTypesCategory,ConfigurationItem._Description,_SHSCalcLocationString,_SHSPhoneNumber,_SHSMDMPlatform,_SHSCellularCarrier,_SHSCellularVoice,_SHSCellularData,ConfigurationItem._SHSDELAsset,ConfigurationItem._SHSVendorPC,ConfigurationItem._SHSAssetOwner,Status,_SHSDeleted,_SHSDeployedTo,_SHSCIPrimaryOwner,_PO,_SHSAssetTag,_CILocation,_RequestID,_IPAddress,_SerialNumber,_Department,_Model,_Manufacture,_SHSTier,_SHSAssetOwner,_SHSLocation3,_SHSWarrantyExpires,_SHSPOANumber,_SHSEpicPrinterWorkflow,_SHSLastAuditDate,_SHSEnvironment,Description,_IncidentQueue,_RequestQueue,_SHSCINotes,CreationDate,CreationUser,LastUpdate,LastUpdateUser,_SHSOperatingSystem,_SHSChassisType,_SHSChasisRef,_HardDiskSize,_RAM,_AvailableDiskSpace,_Model,_SHSKioskRoleName,_SerialNumber,_IPAddress,_SHSMACAddress,_LocationDetails,_DisplayName&V=*'
if (($PSCmdlet.ParameterSetName -ne "Default") -and ($PSCmdlet.ParameterSetName -ne "_ConfigTypesCategory") ) {
$FinalUri = $SearchURI + '&cns=' + $PSCmdlet.ParameterSetName + '-e-0-_a__SHSDeleted-e-1&c0=' + $PSBoundParameters.Values + '&c1=False'
}
elseif ($PSCmdlet.ParameterSetName -eq "_ConfigTypesCategory") {
if ($PSBoundParameters.Values -eq 'Workstation') {
$FinalUri = $SearchURI + '&cns=' + $PSCmdlet.ParameterSetName + '-e-0-_a__SHSDeleted-e-1&c0=' + '9dadd9f9-ca5d-4be6-93cc-6c8745fff615' + '&c1=False'
}
else {
# Printer
$FinalUri = $SearchURI + '&cns=' + $PSCmdlet.ParameterSetName + '-e-0-_a__SHSDeleted-e-1&c0=' + 'd1e6d576-a18f-4703-b431-c859f1c222ee' + '&c1=False'
}
}
else {
Write-Verbose "DEfault"
$FinalUri = $SearchURI
}
$SearchResults = (Invoke-RestMethod -Uri $FinalUri -Headers $headers -Method get).DataRows
return $SearchResults
}
end {
}
}
function Get-CMDBData {
[CmdletBinding()]
param (
[Parameter()]
[string]
$comp,
[string]
$asset
)
if($asset -match "\w \w"){
$asset = $asset -split ' '
$asset = $asset[0]
}
$cmdb = Get-LANDeskCMDBItem -Name $comp
if ($null -eq $cmdb){
try { $cmdb = Get-LANDeskCMDBItem -AssetTag $asset} catch{ $cmdb = $null }
}
return $cmdb
}

View file

@ -0,0 +1,54 @@
function Get-LastLoginTimes {
[CmdletBinding()]
param (
[Parameter()]
[String]
$ComputerName = $ENv:COMPUTERNAME
)
$sb = {
$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){
$dec2 = 0
$a = '{0:x}' -f $prop.LocalProfileUnLoadTimeHigh
$b = '{0:x}' -f $prop.LocalProfileUnLoadTimeLow
$dec1 = [bigint]::Parse("$a$b",'AllowHexSpecifier')
if($prop.LocalProfileLoadTimeHigh -and $prop.LocalProfileLoadTimeLow){
$c = '{0:x}' -f $prop.LocalProfileLoadTimeHigh
$d = '{0:x}' -f $prop.LocalProfileLoadTimeLow
$dec2 = [bigint]::Parse("$c$d",'AllowHexSpecifier')
}
if ($dec2 -gt $dec1) {
$dec = $dec2
}
else {
$dec = $dec1
}
$time = w32tm /ntte $dec
$lastTime = [datetime]($time -split ' - ')[1]
}
else{
$lastTime = $null
}
[PSCustomObject]@{
Name = ($_.LocalPath -split 'C:\\Users\\')[1]
LocalPath = $_.LocalPath
LastLoginTime = $lastTime
}
}
}
if($ComputerName -eq $ENv:COMPUTERNAME){
Invoke-Command -ScriptBlock $sb | Sort-Object LastLoginTime -Descending
}
else{
Invoke-Command -ComputerName $ComputerName -ScriptBlock $sb | Select-Object Name, LocalPath, LastLoginTime | Sort-Object LastLoginTime -Descending
}
}

View file

@ -0,0 +1,42 @@
function Get-LastLoginTimes {
[CmdletBinding()]
param (
[Parameter()]
[String]
$ComputerName = $ENv:COMPUTERNAME
)
$sb = {
$profiles = Get-CimInstance -Class Win32_UserProfile
$profiles | Where {$_.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 = $null
}
[PSCustomObject]@{
Name = ($_.LocalPath -split 'C:\\Users\\')[1]
LocalPath = $_.LocalPath
LastLoginTime = $lastTime
}
}
}
if($ComputerName -eq $ENv:COMPUTERNAME){
Invoke-Command -ScriptBlock $sb | Sort-Object LastLoginTime -Descending
}
else{
Invoke-Command -ComputerName $ComputerName -ScriptBlock $sb | Select-Object Name, LocalPath, LastLoginTime | Sort-Object LastLoginTime -Descending
}
}

14
Private/Get-USB.ps1 Normal file
View file

@ -0,0 +1,14 @@
#pulls some basic usb device info from the the WMI
function Get-USB {
param(
[string]$comp
)
process{
try {
Get-WmiObject Win32_USBControllerDevice -ComputerName $comp | ForEach-Object {[wmi]($_.Dependent)} | Sort-Object Manufacturer,Description,DeviceID | Format-Table -GroupBy Manufacturer Description,Service,DeviceID
}
catch{
Write-warning 'Unable to grab USB info'
}
}
}

View file

@ -0,0 +1,17 @@
Function HostnamesByPrinter($ComputerName){
$SiteName="100"
$SCCMServer="shscm01.int.samhealth.net"
$SCCMNameSpace="root\sms\site_100"
$FindHostnamesByPrinterQuery = "select SMS_R_System.Name from SMS_R_System inner join SMS_G_System_PRINTER_DEVICE on
SMS_G_System_PRINTER_DEVICE.ResourceId = SMS_R_System.ResourceId where SMS_G_System_PRINTER_DEVICE.Name = '$ComputerName'"
$FindHostnamesByPrinterSCCM = Get-WmiObject -namespace $SCCMNameSpace -DirectRead -computer $SCCMServer -query $FindHostnamesByPrinterQuery |
Select-Object -ExpandProperty Name
Return $FindHostnamesByPrinterSCCM
}

43
Private/InstallNet35.ps1 Normal file
View file

@ -0,0 +1,43 @@
function Get-InstallNet35 {
<#
.SYNOPSIS
This function takes a hostname and silently installs .Net 3.5 on target computer
.DESCRIPTION
Use this function to install .Net 3.5 onto a remote computer without interrupting the user.
Function has been connected to Get-PC and can be run with Get-PC Hostname -InstallNet35
.NOTES
Version: 1.0
Author: Jake Castadio
Creation Date: 1/16/2023
Purpose/Change: Created to assist with legacy app installs
.Example
Get-PC AEPIS00000 -InstallNet35
#>
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[string]$HostName
)
if(Test-Connection -ComputerName $HostName -Count 1) {
Invoke-Command -ComputerName $HostName -ScriptBlock {
Enable-WindowsOptionalFeature -Online -FeatureName NetFx3 -Source \\shscm01\packages\Microsoft\dotNet\3.5 -LimitAccess -All
} -AsJob -JobName installNet
Wait-Job -Name installNet
Remove-Job -Name installNet
} else {
Write-Host "Unable to enable .Net 3.5, workstation may be offline"
}
}

View file

@ -0,0 +1,27 @@
function Invoke-CMDBweblaunch {
param {
[string]$comp
}
Write-Host "Querying CMDB..."
try { $cmdbData = Get-LANDeskCMDBItem -Name $comp } catch { $cmdbData = $null}
if($null -eq $cmdbData){
Write-Host "CMDB hostname mismatch" -ForegroundColor Yellow
Write-Host "Running Get-PC Lookup for asset tag"
$getpcData = get-pc $comp
try { $cmdbData = Get-LANDeskCMDBItem -AssetTag $getpcData.'Asset Tag'} catch{ $cmdbData = $null }
if($null -eq $cmdbData){
Write-Warning "Unable to find record with assset tag in CMDB"
Write-Host "Unable to launch record page" -ForegroundColor Yellow
return
}
}
Write-Host "CMDB record found - launching Landesk page in IE"
$uri = "https://shslandesk/WebAccess/wd/object/open.rails?class_name=_CMDBManagement.Call&key="
$fulluri = $uri + $cmdbData.key
Start-Process $fulluri
return
}

69
Private/LogOffUser.ps1 Normal file
View file

@ -0,0 +1,69 @@
Function Get-LogOffUser($ComputerName){
Try
{
$userName = (Get-CimInstance -Class win32_computersystem -ComputerName $ComputerName).UserName
if(!$userName)
{
$userName = "**None**"
Write-Host "No logged in user on $ComputerName" -ForegroundColor Green
return
}else{
Write-Host "You are about to remotely logoff [$userName] from this [$ComputerName]"
}
}
Catch
{
Write-Host "Could not connect to the target computer.`nCheck that the computer is powered on and the name is typed correctly." -ForegroundColor Yellow -BackgroundColor DarkCyan
}
#Displays the username for the current user, then prompts for a 'Yes' or 'No (Cancel)'
$yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes (Logoff $username)"
$no = New-Object System.Management.Automation.Host.ChoiceDescription "&No (Cancel)"
$options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)
$result = $host.ui.PromptForChoice($title, $message, $options, 0)
#If you select Yes, then the following switch (0) runs
#If you select No, then a message displays and the script will exit
Switch ($result)
{
0{
#If you've gotten this far, then $computerWMI should have connected successfully to the remote computer
#There is also a user logged in, and the correct user has been confirmed by pressing the 'Yes' button
#This portion of the switch connects to the Win32_OperatingSystem class, then issues a logoff command
Write-host "Attempting to logoff [$userName] from [$ComputerName]." -ForegroundColor Yellow
Try
{
(Get-WmiObject -Class win32_operatingsystem -ComputerName $ComputerName -ErrorAction Stop).Win32Shutdown(4) | out-null
Start-Sleep -s 5
Write-Host "User should now be logged off." -ForegroundColor Green
}
Catch
{
Write-Host "Could not connect to the target [$ComputerName]. `nPlease verify that the computer is still powered on and is on the Samaritan network." -ForegroundColor Yellow -BackgroundColor Red
}
}
#This only happens if the user selects "No." Displays a message, then exits the script.
1{
Write-host "Canceling logging off user." -ForegroundColor Yellow
}
}
}

View file

@ -0,0 +1,46 @@
function Find-NextPrinterName($printerPrefix){
<#if($printerPrefix -eq $null){
$printerPrefix = Read-Host "Printer Prefix"
}
#>
$printerNames = @()
$printerPrefix = Read-Host "Printer Prefix"
$printerNumber = 1
$printerName = ''
$hit = $true
$domains = @('','.gsrmc.int.samhealth.net','.avery.int.samhealth.net','.sagh.int.samhealth.net','.snlh.int.samhealth.net','.slch.int.samhealth.net','.spch.int.samhealth.net')
for ($i=0; $i -lt 5; $i++){
#Write-Host $printerNumber
while($hit -eq $true){
$hit = $false
$printerName = "{0}{1:d2}" -f ($printerPrefix,$printerNumber)
#Write-Host $printerName
foreach ($domain in $domains){
$printerHost = "$printerName$domain"
#Write-Host $printerHost
$testHost = Resolve-DnsName $printerHost
if($testHost -ne $null) {
$hit = $true
}
}
#Write-Host $printerHost
#Write-HOst $nslookup
if($hit -eq $true){
$printerNumber++
}
}
$printerNames += $printerName
$printerNumber++
$hit = $true
}
#Write-Host "$printerName"
return $printerNames
}

103
Private/PCCleanup.ps1 Normal file
View file

@ -0,0 +1,103 @@
Function Get-PCCleanup($ComputerName){
Write-Host 'Starting PC Cleanup'
Write-Host 'Clearing Windows Temp'
if(Test-Path \\$ComputerName\C$\Windows\Temp){
Get-ChildItem -Path \\$ComputerName\C$\Windows\Temp -Recurse -Force | Remove-Item -Force -Recurse
Write-Host "Cleaned up files in \\$ComputerName\C$\Windows\Temp " -ForegroundColor Green
}else{
Write-Host "Could not access \\$ComputerName\C$\Windows\Temp" -ForeGround Red
}
Write-Host 'Clearing PACS Web Cache'
if(Test-Path \\$ComputerName\C$\DRS\LocalCache\PACS-Web){
Get-ChildItem -Path \\$ComputerName\C$\DRS\LocalCache\PACS-Web -Recurse -Force | Remove-Item -Force -Recurse
Write-Host "Cleaned all files in \\$ComputerName\C$\DRS\LocalCache\PACS-Web" -ForegroundColor Green
}else{
Write-Host "Could not access \\$ComputerName\C$\DRS\LocalCache\PACS-Web" -ForeGround Red
}
Write-Host 'Clearing Brance cache'
try { Clear-BCCache -Force
Write-Host 'Cleared branch cache' -ForegroundColor Green
}
catch {Write-Host 'Unable to clear branch cache' -ForegroundColor Yellow}
}
Function Get-PCProfileCleanup($ComputerName){
$diskspace = Get-FreeDiskSpace $ComputerName
$out1 = "Free Space on " + $computerName + ": "
$out2 = $diskspace.'Free Space'
$out3 = " GB/" + $diskspace.'Total Space' + ' GB'
Write-Host $out1 -NoNewline
if($diskspace.'Free Space' -lt 5){
Write-Host $out2 -ForegroundColor Red -NoNewline
}
elseif($diskspace.'Free Space' -lt 10){
Write-Host $out2 -ForegroundColor Yellow -NoNewline
}
else{
Write-Host $out2 -NoNewline
}
Write-Host $out3
if($null -eq $ComputerName){
$ComputerName = $env:COMPUTERNAME
}
$userInput = Read-Host "Do you wish to proceed with removing inactive user profiles older than X days? (y/n)"
if($userInput -ne "y"){
Write-Host "No user profiles deleted"
return
}
$days = Read-Host "Clean up user profiles inactive for more than x days"
$allProfiles = Get-LastLoginTimes -ComputerName $ComputerName
$userProfiles = $allProfiles | Where-Object {$_.LastLoginTime -lt $(Get-Date).Date.AddDays(-$days)}
$userProfiles += $allProfiles | Where-Object LastLoginTime -eq 'Unknown'
#$userProfiles = Get-CIMInstance -ComputerName $ComputerName -Class Win32_UserProfile | Where {$_.LastUseTime -lt $(Get-Date).Date.AddDays(-$days)}
$userAmount = 0
foreach ($user in $userProfiles) {
$output = "{0} | {1:MM}/{1:dd}/{1:yyyy}" -f $user.Name, $user.LastLoginTime
Write-Host $output
$userAmount++
}
Write-host "There are $userAmount profiles inactive more than $days days"
if($userProfiles){
Write-Host "WARNING: ALL PROFILES DELETED ARE UNRETRIEVABLE" -ForegroundColor Yellow
$delChoice = Read-Host "Delete these users (y/n)"
}
else {
Write-Host "No users inactive for more than $days days"
}
if ($delChoice -eq 'y'){
$current = 0
foreach ($user in $userProfiles){
$current++
Write-Progress -Activity "Deleting Profiles" -Status "$current / $userAmount" -PercentComplete ($current/$userAmount*100) -CurrentOperation $user.LocalPath
Write-Host "Deleting " $user.LocalPath " | " $user.LastLoginTime
Get-CIMInstance -Class Win32_UserProfile -ComputerName $ComputerName | Where-Object { $_.LocalPath -eq $user.LocalPath } | Remove-CIMInstance -Verbose
}
Write-Host "$current profiles have been deleted"
$newDiskspace = Get-FreeDiskSpace $ComputerName
[int]$percentFreed = (($newDiskspace.'Free Space' - $diskspace.'Free Space') / $diskspace.'Total Space') * 100
$out = "Free Space on " + $computerName + ": " + $newDiskspace.'Free Space' + "GB/" + $newDiskspace.'Total Space' + 'GB' + " ($percentFreed% Freed)"
Write-Host $out
}
}

325
Private/PCLocal.ps1 Normal file
View file

@ -0,0 +1,325 @@
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'
$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
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

45
Private/PCReboot.ps1 Normal file
View file

@ -0,0 +1,45 @@
Function Get-PCReboot($ComputerName){
$title = "You are about to reboot $ComputerName, are you sure?"
$yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes"
$no = New-Object System.Management.Automation.Host.ChoiceDescription "&No"
$options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)
$result = $host.ui.PromptForChoice($title, $decision, $options, 0)
switch($result)
{
0{
Write-host "Attempting to Reboot $ComputerName." -ForegroundColor Yellow
Write-Host "Executing Bypass..."
Invoke-Command -ComputerName $ComputerName -ScriptBlock {
If (Test-Path 'C:\Program Files (x86)\PGP Corporation\PGP Desktop\PGPwde.exe')
{
& "C:\Program Files (x86)\PGP Corporation\PGP Desktop\PGPwde.exe" --remove-bypass --admin-passphrase handshake1 --aa
& "C:\Program Files (x86)\PGP Corporation\PGP Desktop\PGPwde.exe" --add-bypass --disk 0 --count 1 --admin-passphrase handshake1 --aa
}
If (Test-Path 'C:\Program Files\PGP Corporation\PGP Desktop\PGPwde.exe')
{
& "C:\Program Files\PGP Corporation\PGP Desktop\PGPwde.exe" --remove-bypass --admin-passphrase handshake1 --aa
& "C:\Program Files\PGP Corporation\PGP Desktop\PGPwde.exe" --add-bypass --disk 0 --count 1 --admin-passphrase handshake1 --aa
}
}
Write-Host "Executing Restart..."
Invoke-Command -ComputerName $ComputerName -ScriptBlock {shutdown -r -t 0}
Write-Host "Reboot Command as been sent"
}
1{
Write-host "You selected 'No' so this script will now exit." -BackgroundColor Red -ForegroundColor Yellow
}
}
}

560
Private/PCRemote.ps1 Normal file
View file

@ -0,0 +1,560 @@
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
}
}

334
Private/PCRemoteCleaned.ps1 Normal file
View file

@ -0,0 +1,334 @@
#GetPC w/ Jobs
#CIM Instance Calls
<#
win32_networkadapterconfiguration | MAC Address,
win32_computersystem | Username, Model, RAM,
win32_LogicalDisk | Diskspace,
win32_bios | ServiceTag, Bios Version,
win32_OperatingSystem | Last Restart, OS Version, OS Build, OS Build Number
win32_SystemEnclosure | Asset Tag
win32_processor | CPU Type
PC Release ID
Installed Printers
#>
#WMI Calls
<#
win32_tpm
#>
#PSSessions
<#
Lastuser/Lastuser timestamp
Imprivata Type
Kiosk Role and Type
MBAM GPO Status
#>
<#
function get-PCremoteCleaned {
param (
[string]$comp,
$connection,
$NumberofComputers,
$PCID
)
$ComputerName = $Comp
$i = 0
$i++ | ProgressBar $i $comp 'NetAdapter' $NumberofComputers $PCID
$win32_networkadapterconfiguration = Get-CimInstance -Class win32_networkadapterconfiguration -ComputerName $ComputerName #| MAC Address,
$i++ | ProgressBar $i $comp 'LogicalDisk' $NumberofComputers $PCID
$win32_LogicalDisk = Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DriveType=3" -ComputerName $ComputerName #| Diskspace,
$i++ | ProgressBar $i $comp 'Enclosure' $NumberofComputers $PCID
$win32_SystemEnclosure = Get-CimInstance -ClassName Win32_SystemEnclosure -ComputerName $ComputerName #| Asset Tag
$i++ | ProgressBar $i $comp 'Bitlocker' $NumberofComputers $PCID
$bitlocker = manage-bde -cn $ComputerName -status C: # | Bitlocker Status
$i++ | ProgressBar $i $comp 'PCInfo' $NumberofComputers $PCID
$PCInfo = Invoke-Command -ComputerName $ComputerName -SessionOption (New-PSSessionOption -NoMachineProfile) -ScriptBlock {get-computerinfo}
$i++ | ProgressBar $i $comp 'PhysicalDisk' $NumberofComputers $PCID
$physicalDisk = Get-PhysicalDisk -CimSession $ComputerName # | Disk Type
$i++ | ProgressBar $i $comp 'Printers' $NumberofComputers $PCID
$win32_printer = (Get-CimInstance -ClassName win32_printer -ComputerName $ComputerName | Where-Object {$_.PortName -ne 'PORTPROMPT:' -and $_.PortName -ne 'nul:' -and $_.PortName -ne 'SHRFAX:'} | Select-Object -ExpandProperty Name) -join ' || ' # | Printers
$i++ | ProgressBar $i $comp 'Imprivata' $NumberofComputers $PCID
$imprivataRegEntry = Invoke-Command -ComputerName $ComputerName -SessionOption (New-PSSessionOption -NoMachineProfile) -ScriptBlock {Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\SSOProvider\ISXAgent}
$kioskRegEntry = Invoke-Command -ComputerName $ComputerName -SessionOption (New-PSSessionOption -NoMachineProfile) -ScriptBlock {Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\SHSCustom}
$i++ | ProgressBar $i $comp 'TPM' $NumberofComputers $PCID
$win32_tpm = Get-CimInstance -Namespace root\cimv2\security\microsofttpm -Class win32_tpm -ComputerName $ComputerName # | TPM
$i++ | ProgressBar $i $comp 'MBAM GPO' $NumberofComputers $PCID
$gpostatus = 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
}
$i++ | ProgressBar $i $comp 'Pulling Citrix' $NumberofComputers $PCID
$CitrixViewer = "\\$ComputerName\C$\Program Files (X86)\Citrix\ICA Client\CDViewer.exe"
$i++ | ProgressBar $i $comp 'Pulling Last users' $NumberofComputers $PCID
$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} # | Last Users
$i++ | ProgressBar $i $comp 'Pulling CPU' $NumberofComputers $PCID
$CPU = (Get-CimInstance -ClassName Win32_processor -ComputerName $ComputerName).Name
#CMDB Location
$i++ | ProgressBar $i $comp 'Pulling CMDB Data' $NumberofComputers $PCID
$location = Get-CMDBLocation $ComputerName
$i++ | ProgressBar $i $comp 'Compiling Data' $NumberofComputers $PCID
#MAC Address
$MAC = ($win32_networkadapterconfiguration | Where-Object {$_.IpEnabled -Match "True"} | Select-Object -Expand macaddress) -join ","
#IP
$ip = $connection.IPV4Address
#UserName
$Username = $PCInfo.CSUserName
if($null -eq $Username){
$Username = (Invoke-Command -SessionOption (New-PSSessionOption -NoMachineProfile) -ComputerName $ComputerName -ScriptBlock {Get-Process Explorer -IncludeUsername | Where-Object { $_.Username -notlike "*SYSTEM" }} ).Username
if($null -ne $Username){
$Username = "$Username (RDP/Inactive)"
}
else{
$Username = '**None**'
}
}
#Last User
if($lastUser.Count -gt 1){
$lastUser1 = ($lastUser[0].Name + " (" + $lastUser[0].LastWriteTime + ")")
$lastUser2 = ($lastUser[1].Name + " (" + $lastUser[1].LastWriteTime + ")")
$lastUser3 = ($lastUser[2].Name + " (" + $lastUser[2].LastWriteTime + ")")
$TotalLastUsers = "$lastUser1 $lastUser2 $lastUser3"
}else{
$TotalLastUsers = $lastUser.Name + " (" + $lastUser.LastWriteTime + ")"
}
#ComputerModel
$compModel = $PCInfo.CsModel
#RAM
$ram = $PCInfo.CsTotalPhysicalMemory
$ram = [math]::Round(($ram / 1GB))
$ram = "$ram" + ' GB'
#Drive Type
$DriveType = $physicalDisk.MediaType
#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
$osBuild = $PCInfo.OSBuildNumber
$osBuild = "Vers $osVer | Build #$osBuild"
#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 = $kioskRegEntry | Select-Object -ExpandProperty KioskRole
if(!$kioskRole){
$kioskRole = "None"
}
#TPM
$tpmStatus = $win32_tpm | Select-Object -ExpandProperty IsEnabled_InitialValue
if($tpmStatus -eq $true){
$tpmStatus = "On & Activated"
}
elseif($tpmStatus -eq $false){
$tpmStatus = "On & Deactivated"
}
else{
$tpmStatus = "TPM Off"
}
#Chassis Type
$chassisType = Get-ChassisTypeNew -CPU $CPU -Model $compModel
#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
}
#Output
$i++ | ProgressBar $i $comp 'Generating Output' $NumberofComputers $PCID
$props = [Ordered]@{
Hostname = "$comp"
Status = "Online"
'Current User' = "$userName"
'Last User(s)' = "$TotalLastUsers"
'IP | MAC' = "$ip | $mac"
Model = "$compModel ($chassisType)"
'OS' = $os
'OS Build' = $osBuild
'BIOS Ver' = "$biosVersion"
Encryption = "$EncryptionStatus"
'Free Space' = "$freespace | $driveType"
RAM = "$ram"
'SSO Client' = "$imprivataType"
'Kiosk Role' = "$kioskRole"
'Citrix Ver' = "$citrixVersion"
'Asset Tag' = "$assetTag"
'Service Tag' = "$serviceTag"
'Last Reboot' = "$lastbootTime"
'TPM Status' = "$tpmStatus"
'MBAM GPO' = "$gpostatus"
Printers = "$printers"
'CMDB Location' = "$location"
}
$obj = New-Object -TypeName PSObject -Property $props
return $obj
}
#Helper Functions
Function Get-ChassisTypeNew {
[CmdletBinding()]
param (
$CPU,
$Model
)
Switch -Wildcard($Model)
{
"Optiplex*" {
Switch -Wildcard($CPU)
{
"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-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"
}
Default {Return "Unknown Model/Chassis"}
}
}
Function Get-CMDBLocation($comp) {
$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
}
#>

19
Private/PCRename.ps1 Normal file
View file

@ -0,0 +1,19 @@
Function Get-PCRename($ComputerName){
if(Test-Connection -ComputerName $ComputerName -Count 1)
{
$User = $env:username
$DomainUser = "int\$User"
Write-Host "Current Hostname: $ComputerName"
$NewHostName = Read-Host "New Hostname"
Rename-Computer -ComputerName $ComputerName -NewName $NewHostName -DomainCredential $DomainUser -force -Restart
Write-Host "Renamed PC, successful. Restarting PC... Old Hostname: $ComputerName, New Hostname: $NewHostName" -ForegroundColor Green
}else{
Write-Host "Unable to connect to PC...Cancelling PCRename script on $ComputerName" -ForegroundColor Red
}
}

View file

@ -0,0 +1,14 @@
Function Get-RemoteDesktopApp($ComputerName){
if(!(Test-Connection -ComputerName $ComputerName -Count 1)){
Write-Host "No connection could be made to $ComputerName..." -ForegroundColor Red
break
}
Write-Host "Starting Remote Desktop Connection to $ComputerName" -ForegroundColor Green
Start-Process "$env:windir\system32\mstsc.exe" -ArgumentList "/v:$ComputerName"
Write-Host "Connecting to $ComputerName" -ForegroundColor Green
}

View file

@ -0,0 +1,27 @@

Function Get-ResetRepository($ComputerName){
Write-Host "Verifying if WMI Repository is corrupt..." -ForegroundColor Yellow
Invoke-Command -ComputerName $ComputerName -SessionOption (New-PSSessionOption -NoMachineProfile) -ScriptBlock{
$isCorrupt = & Winmgmt /verifyrepository
if($isCorrupt -eq "WMI repository is consistent"){
Write-Host "WMI repository is consistent, no need to reset repository on $Using:ComputerName" -ForegroundColor Green
break
}else{
Write-Host "WMI repository is corrupt, resetting repository on $Using:ComputerName" -ForegroundColor Red
Write-Host "Will attempt to Salvage Repository..."
& Winmgmt /salvagerepository
Write-Host "Salvage Repository has finished." -ForegroundColor Green
}
}
}

66
Private/Resources.ps1 Normal file
View file

@ -0,0 +1,66 @@
function get-resources {
param ( $pc )
$sBlock = {
try {$win32_LogicalDisk = Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DriveType=3" } catch {$win32_LogicalDisk = $null} #| Diskspace
$obj = New-Object -TypeName PSObject
# Get system information
$sysInfo = Get-WmiObject -Class Win32_OperatingSystem
$sysProc = Get-WmiObject -Class Win32_Processor
$sysMem = Get-WmiObject -Class Win32_PhysicalMemory
# Get processor usage
$procUsage = [math]::Round((Get-Counter '\Processor(_Total)\% Processor Time').CounterSamples.CookedValue)
# Get memory usage
$memUsage = [Math]::Round((1 - (Get-Counter '\Memory\Available MBytes').CounterSamples.CookedValue/($sysMem.Capacity/1MB))*100,1)
# Get Physical Network Adapter information
$netAdapters = Get-NetAdapter -physical | Where-Object status -eq 'up'
#Free Harddrive Space
$CompFreeSpace = @([math]::Round($win32_LogicalDisk.FreeSpace / 1gb,2),[math]::Round($win32_LogicalDisk.Size / 1gb,2))
$freeDisk = $compFreeSpace[0]
$maxDisk = $compfreeSpace[1]
$obj | Add-Member -MemberType NoteProperty -Name 'OS' -Value $($sysInfo.Caption)
$obj | Add-Member -MemberType NoteProperty -Name 'Version' -Value $($sysInfo.Version)
$obj | Add-Member -MemberType NoteProperty -Name 'TotalMem' -Value $($sysMem.Capacity/1GB)
$obj | Add-Member -MemberType NoteProperty -Name 'MemUsage' -Value $memUsage
$obj | Add-Member -MemberType NoteProperty -Name 'Processor' -Value $($sysProc.Name)
$obj | Add-Member -MemberType NoteProperty -Name 'NumberOfCores' -Value $($sysProc.NumberOfCores)
$obj | Add-Member -MemberType NoteProperty -Name 'ProcUsage' -Value $procUsage
$obj | Add-Member -MemberType NoteProperty -Name 'NetAdapters' -Value $netAdapters
$obj | Add-Member -MemberType NoteProperty -Name 'freeDisk' -Value $freeDisk
$obj | Add-Member -MemberType NoteProperty -Name 'maxDisk' -Value $maxDisk
return $obj
}
$output = @()
$output += Invoke-Command -ScriptBlock $sblock -ComputerName $pc -SessionOption (New-PSSessionOption -NoMachineProfile -OpenTimeout 45000) | Select-Object * -ExcludeProperty RunspaceId, PSComputerName, PSShowComputerName
# Display system information
Write-Host "System Information:"
Write-Host "-------------------"
Write-Host "Computer Name: $pc"
Write-Host "Operating System: $($output.OS)"
Write-Host "Version: $($output.Version)"
Write-Host "Total Physical Memory: $($output.TotalMem) GB, Memory Usage: $($output.memUsage) %"
Write-Host "Processor: $($output.Name) $($output.NumberOfCores) cores, Processor Usage: $($output.procUsage)%"
Write-Host "Disk Space: $($output.freeDisk) GB / $($output.maxDisk) GB"
Write-Host "-------------------"
Write-Host "Physical Network Adapters:"
foreach ($netAdapter in $output.netAdapters) {
$speed = $netAdapter.Speed
if ($speed -gt 1000000000) {
$speed = "{0} Gbps" -f ($speed/1000000000)
} else {
if($speed -gt 1000000){
$speed = "{0} Mbps" -f ($speed/1000000)
}
}
Write-Host "Name: $($netAdapter.InterfaceDescription) Type: $($netAdapter.name), Link Speed: $speed"
}
}

416
Private/SCCMQuery.ps1 Normal file
View file

@ -0,0 +1,416 @@
#CONST
$SITENAME="100"
$SCCMSERVER="shscm01.int.samhealth.net"
$SCCMNAMESPACE="root\sms\site_100"
Function Get-SCCMQuery {
param (
[string]$comp,
[int]$NumberofComputers,
[int]$PCID
)
if(!(Test-Connection -ComputerName $comp -Count 1)){
$compStatus = "Offline"
}
else{
$compStatus = "Online"
}
if(get-module -ListAvailable -Name 'ActiveDirectory'){
try { $adTest = ((Get-ADComputer $comp).DistinguishedName -match "Disabled Computers") } catch { $adTest = $true }
if($adTest){
$compStatus += " (disabled or off the domain)"
}
}
$i = 0
$i++ | ProgressBar $i $comp "SCCM Last Hardware Scan" $NumberofComputers $PCID
$FindLastHardwareScanSCCM = Get-SCCMLastHardwareScan $comp
if(!$FindLastHardwareScanSCCM){
$props = [Ordered]@{
Hostname = "$comp"
Status = "$compStatus"
'Current User' = $null
'Last User(s)' = $null
'IP | MAC' = $null
Model = $null
'OS' = $null
'OS Build' = $null
'BIOS Ver' = $null
Encryption = $null
'Free Space' = $null
RAM = $null
'SSO Client' = $null
'Kiosk Role' = $null
'Asset Tag' = $null
'Service Tag' = $null
'Last Reboot' = $null
Printers = $null
}
$obj = New-Object -TypeName PSObject -Property $props
return $obj
}
$i++ | ProgressBar $i $comp "Last User SCCM" $NumberofComputers $PCID
$LastUserSCCM = Get-SCCMLastUserLogOnQuery $comp
$i++ | ProgressBar $i $comp "SCCM IP Query" $NumberofComputers $PCID
$FindIPSCCM = Get-SCCMIPQuery $comp
$i++ | ProgressBar $i $comp "Find Model SCCM" $NumberofComputers $PCID
$CompModelSCCM = Get-SCCMFindModelQuery $comp
$i++ | ProgressBar $i $comp "SCCM Bios Version" $NumberofComputers $PCID
$FindBiosVerSCCM = Get-SCCMBiosVerQuery $comp
$i++ | ProgressBar $i $comp "SCCM HDD/SSD Space" $NumberofComputers $PCID
$CompFreeSpaceSCCMGB = Get-SCCMFindFreeSpaceQuery $comp
$i++ | ProgressBar $i $comp "SCCM RAM" $NumberofComputers $PCID
$FindMemorySCCMGB = Get-SCCMFindMemoryQuery $comp
$i++ | ProgressBar $i $comp "SCCM Asset Tag" $NumberofComputers $PCID
$FindAssetTagSCCM = Get-SCCMFindAssetTagQuery $comp
$i++ | ProgressBar $i $comp "SCCM Service Tag" $NumberofComputers $PCID
$FindServiceTagSCCM = Get-SCCMServiceTagQuery $comp
$i++ | ProgressBar $i $comp "SCCM OS Name" $NumberofComputers $PCID
$FindOSNameSCCM = Get-SCCMFindOSNameQuery $comp
$i++ | ProgressBar $i $comp "SCCM OS Architecture" $NumberofComputers $PCID
$FindOSArchSCCM = Get-SCCMFindOSArch $comp
$i++ | ProgressBar $i $comp "SCCM OS Build" $NumberofComputers $PCID
$FindOSBuild = Get-SCCMFindOSBuild $comp
$i++ | ProgressBar $i $comp "SCCM Encryption" $NumberofComputers $PCID
$FindEncryptionSCCM = Get-SCCMFindEncryption $comp
$i++ | ProgressBar $i $comp "SCCM Last Boot Up Time" $NumberofComputers $PCID
$FindLastBootUpTimeSCCM = Get-SCCMLastBootUpTime $comp
$i++ | ProgressBar $i $comp "SCCM Printers" $NumberofComputers $PCID
$FindPCPrinterSCCM = Get-SCCMPCPrinter $comp
$i++ | ProgressBar $i $comp "SCCM MACAddress" $NumberofComputers $PCID
$FindMACAddressSCCM = Get-SCCMFindMACAddress $comp
$i++ | ProgressBar $i $comp "SCCM Chassis Type" $NumberofComputers $PCID
$FindChassisTypeSCCM = Get-SCCMChassisType($comp)
if($FindAssetTagSCCM -is [array]){
Write-Warning "Dupe record in SCCM - $comp"
$FindAssetTagSCCM = $FindAssetTagSCCM[0]
<#Get-CMDBFallback $comp#>
}
<#$cmdbData = Get-CMDBData $comp $FindAssetTagSCCM
$MDBLcmdblocation = Get-Cocation $cmdbData
#>
if($FindLastHardwareScanSCCM){
Write-Host "`n`nPulling cached SCCM data for $comp." -ForegroundColor Yellow
Write-Host "Last Hardware Scan Time: $FindLastHardwareScanSCCM" -ForegroundColor Yellow
}
$props = [Ordered]@{
Hostname = "$comp"
Status = "$compStatus"
'Current User' = "Not Available"
'Last User(s)' = "$LastUserSCCM"
'IP | MAC' = "$FindIPSCCM | $FindMACAddressSCCM"
Model = "$CompModelSCCM ($FindChassisTypeSCCM)"
'OS' = "$FindOSNameSCCM" + " ($FindOSArchSCCM)"
'OS Build' = "Build #$FindOSBuild"
'BIOS Ver' = "$FindBiosVerSCCM"
Encryption = "$FindEncryptionSCCM"
'Free Space' = "$CompFreeSpaceSCCMGB" + " GB"
RAM = "$FindMemorySCCMGB" + " GB "
'SSO Client' = "Not Available"
'Kiosk Role' = "Not Available"
'Asset Tag' = "$FindAssetTagSCCM"
'Service Tag' = "$FindServiceTagSCCM"
'Last Reboot' = "$FindLastBootUpTimeSCCM"
Printers = "$FindPCPrinterSCCM"
}
$obj = New-Object -TypeName PSObject -Property $props
<#if($cmdbData.values.ConfigurationItem._SHSDELAsset -eq 'True'){
$delInfo = Get-CMDBDELInfo $cmdbData
$obj | Add-Member -MemberType NoteProperty -Name 'DEL Owner' -Value $delInfo.Owner
$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
}
Function Get-SCCMLastUserLogOnQuery($ComputerName){
$SCCMLastUserLogOnQuery = "select SMS_R_System.LastLogonUserName from SMS_R_System where SMS_R_System.Name = '$ComputerName'"
$LastUserSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $SCCMLastUserLogOnQuery |
Select-Object -ExpandProperty LastLogonUserName
Return $LastUserSCCM
}
Function Get-SCCMIPQuery($ComputerName){
$FindIPQuery = "select SMS_R_System.IPAddresses from SMS_R_System where SMS_R_System.Name = '$ComputerName'"
$FindIPSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindIPQuery |
Select-Object -ExpandProperty IPAddresses
if($FindIPSCCM.Count -gt 1){
Return $FindIPSCCM[0]
}else{
Return $FindIPSCCM
}
}
Function Get-SCCMFindMACAddress($ComputerName){
$FindMacAddressQuery = "select SMS_R_System.MACAddresses from SMS_R_System where SMS_R_System.Name = '$ComputerName'"
$FindMacAddressSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindMacAddressQuery | Select-Object -ExpandProperty MACAddresses
if($FindMacAddressSCCM.Count -gt 1){
Return $FindMacAddressSCCM[0]
}else{
Return $FindMacAddressSCCM
}
}
Function Get-SCCMFindModelQuery($ComputerName){
$FindModelQuery = "select SMS_G_System_COMPUTER_SYSTEM.Model from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on
SMS_G_System_COMPUTER_SYSTEM.ResourceId = SMS_R_System.ResourceId where SMS_R_System.Name = '$ComputerName'"
$CompModelSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindModelQuery |
Select-Object -ExpandProperty Model
Return $CompModelSCCM
}
Function Get-SCCMFindFreeSpaceQuery($ComputerName){
$FindFreeSpaceQuery = "select SMS_G_System_LOGICAL_DISK.Size from SMS_R_System inner join SMS_G_System_LOGICAL_DISK on
SMS_G_System_LOGICAL_DISK.ResourceID = SMS_R_System.ResourceId where SMS_R_System.Name = '$ComputerName'"
$CompFreeSpaceSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindFreeSpaceQuery |
Select-Object -ExpandProperty Size
$CompFreeSpaceSCCMGB = [math]::Round(($CompFreeSpaceSCCM / 1000), 2)
Return $CompFreeSpaceSCCMGB
}
Function Get-SCCMFindMemoryQuery($ComputerName){
$FindMemoryQuery = "select SMS_G_System_X86_PC_MEMORY.TotalPhysicalMemory from SMS_R_System inner join SMS_G_System_X86_PC_MEMORY on
SMS_G_System_X86_PC_MEMORY.ResourceID = SMS_R_System.ResourceId where SMS_R_System.Name = '$ComputerName'"
$FindMemorySCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindMemoryQuery |
Select-Object -ExpandProperty TotalPhysicalMemory
$FindMemorySCCMGB = [math]::Round($FindMemorySCCM / 1MB)
Return $FindMemorySCCMGB
}
Function Get-SCCMFindOSNameQuery($ComputerName){
$FindOSNameQuery = "select SMS_G_System_OPERATING_SYSTEM.Caption, SMS_G_System_OPERATING_SYSTEM.OSArchitecture, SMS_G_System_OPERATING_SYSTEM.BuildNumber from
SMS_R_System inner join SMS_G_System_OPERATING_SYSTEM on SMS_G_System_OPERATING_SYSTEM.ResourceID =
SMS_R_System.ResourceId where SMS_R_System.Name = '$ComputerName'"
$FindOSNameSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindOSNameQuery |
Select-Object -ExpandProperty Caption
Return $FindOSNameSCCM
}
Function Get-SCCMFindOSArch ($ComputerName){
$FindOSNameQuery = "select SMS_G_System_OPERATING_SYSTEM.Caption, SMS_G_System_OPERATING_SYSTEM.OSArchitecture, SMS_G_System_OPERATING_SYSTEM.BuildNumber from
SMS_R_System inner join SMS_G_System_OPERATING_SYSTEM on SMS_G_System_OPERATING_SYSTEM.ResourceID =
SMS_R_System.ResourceId where SMS_R_System.Name = '$ComputerName'"
$FindOSArchSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindOSNameQuery |
Select-Object -ExpandProperty OSArchitecture
Return $FindOSArchSCCM
}
Function Get-SCCMFindOSBuild ($ComputerName){
$FindOSNameQuery = "select SMS_G_System_OPERATING_SYSTEM.Caption, SMS_G_System_OPERATING_SYSTEM.OSArchitecture, SMS_G_System_OPERATING_SYSTEM.BuildNumber from
SMS_R_System inner join SMS_G_System_OPERATING_SYSTEM on SMS_G_System_OPERATING_SYSTEM.ResourceID =
SMS_R_System.ResourceId where SMS_R_System.Name = '$ComputerName'"
$FindOSBuild = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindOSNameQuery |
Select-Object -ExpandProperty BuildNumber
Return $FindOSBuild
}
Function Get-SCCMBiosVerQuery($ComputerName){
$FindBiosVerQuery = "select SMS_G_System_PC_BIOS.SMBIOSBIOSVersion from SMS_R_System inner join SMS_G_System_PC_BIOS on
SMS_G_System_PC_BIOS.ResourceId = SMS_R_System.ResourceId where SMS_R_System.Name = '$ComputerName'"
$FindBiosVerSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindBiosVerQuery |
Select-Object -ExpandProperty SMBIOSBIOSVersion
Return $FindBiosVerSCCM
}
Function Get-SCCMServiceTagQuery($ComputerName){
$FindServiceTagQuery = "select SMS_G_System_SYSTEM_ENCLOSURE.SerialNumber from SMS_R_System inner join SMS_G_System_SYSTEM_ENCLOSURE on
SMS_G_System_SYSTEM_ENCLOSURE.ResourceId = SMS_R_System.ResourceId where SMS_R_System.Name = '$ComputerName'"
$FindServiceTagSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindServiceTagQuery |
Select-Object -ExpandProperty SerialNumber
Return $FindServiceTagSCCM
}
Function Get-SCCMFindAssetTagQuery($ComputerName){
$FindAssetTagQuery = "select SMS_G_System_SYSTEM_ENCLOSURE.SMBIOSAssetTag from SMS_R_System inner join SMS_G_System_SYSTEM_ENCLOSURE on
SMS_G_System_SYSTEM_ENCLOSURE.ResourceId = SMS_R_System.ResourceId inner join SMS_G_System_SYSTEM on SMS_G_System_SYSTEM.ResourceId = SMS_R_System.ResourceId where SMS_G_System_SYSTEM.Name = '$ComputerName'"
$FindAssetTagSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindAssetTagQuery |
Select-Object -ExpandProperty SMBIOSAssetTag
Return $FindAssetTagSCCM
}
Function Get-SCCMFindEncryption($ComputerName){
$FindEncryptionQuery = "select SMS_G_System_ENCRYPTABLE_VOLUME.ProtectionStatus from SMS_R_System inner join SMS_G_System_ENCRYPTABLE_VOLUME on
SMS_G_System_ENCRYPTABLE_VOLUME.ResourceId = SMS_R_System.ResourceId where SMS_R_System.Name = '$ComputerName'"
$FindEncryptionSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindEncryptionQuery |
Select-Object -ExpandProperty ProtectionStatus
Switch($FindEncryptionSCCM){
0{$FindEncryptionSCCM = "BitLocker (Disabled)"}
1{$FindEncryptionSCCM = "BitLocker (Enabled [Unlocked])"}
2{$FindEncryptionSCCM = "BitLocker (Enabled [Locked])"}
Default{$FindEncryptionSCCM = "Encryption Not Found"}
}
Return $FindEncryptionSCCM
}
Function Get-SCCMLastBootUpTime($ComputerName){
$FindLastBootUpTimeQuery = "select SMS_G_System_OPERATING_SYSTEM.LastBootUpTime from SMS_R_System inner join SMS_G_System_OPERATING_SYSTEM on
SMS_G_System_OPERATING_SYSTEM.ResourceId = SMS_R_System.ResourceId where SMS_R_System.Name = '$ComputerName'"
$FindLastBootUpTimeSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindLastBootUpTimeQuery |
Select-Object -ExpandProperty LastBootUpTime
if($null -eq $FindLastBootUpTimeSCCM){
return $null
}
$Year = $FindLastBootUpTimeSCCM.substring(0,4)
$Month = $FindLastBootUpTimeSCCM.substring(4,2)
$Day = $FindLastBootUpTimeSCCM.substring(6,2)
$Hour = $FindLastBootUpTimeSCCM.substring(8,2)
$Minute = $FindLastBootUpTimeSCCM.substring(10,2)
$Second = $FindLastBootUpTimeSCCM.substring(12,2)
$LastBootUpTime = "$Month/$Day/$Year $Hour" + ":" + "$Minute" + ":" + "$Second"
Return $LastBootUpTime
}
Function Get-SCCMPCPrinter($ComputerName){
$FindPCPrinterQuery = "select SMS_G_System_PRINTER_DEVICE.Name, SMS_G_System_PRINTER_DEVICE.PortName from SMS_R_System inner join SMS_G_System_PRINTER_DEVICE
on SMS_G_System_PRINTER_DEVICE.ResourceID = SMS_R_System.ResourceId where SMS_R_System.Name = '$ComputerName'"
$FindPCPrinterSCCM = (Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindPCPrinterQuery |
Where-Object -Property PortName -ne nul: |
Where-Object -Property PortName -ne PORTPROMPT: |
Where-Object -Property PortName -ne SHRFAX: | Select-Object -ExpandProperty Name) -join ' || '
Return $FindPCPrinterSCCM
}
Function Get-SCCMLastHardwareScan($ComputerName){
$FindLastHardwareScanQuery = "select SMS_G_System_WORKSTATION_STATUS.LastHardwareScan from SMS_R_System inner join SMS_G_System_WORKSTATION_STATUS on SMS_G_System_WORKSTATION_STATUS.ResourceID = SMS_R_System.ResourceId where SMS_R_System.Name = '$ComputerName'"
$FindLastHardwareScanSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindLastHardwareScanQuery | Select-Object -ExpandProperty LastHardwareScan
if($null -eq $FindLastHardwareScanSCCM){
return $null
}
$Year = $FindLastHardwareScanSCCM.substring(0,4)
$Month = $FindLastHardwareScanSCCM.substring(4,2)
$Day = $FindLastHardwareScanSCCM.substring(6,2)
$Hour = $FindLastHardwareScanSCCM.substring(8,2)
$Minute = $FindLastHardwareScanSCCM.substring(10,2)
$Second = $FindLastHardwareScanSCCM.substring(12,2)
$LastBootUpTime = "$Month/$Day/$Year $Hour" + ":" + "$Minute" + ":" + "$Second"
Return $LastBootUpTime
}
Function Get-SCCMChassisType($ComputerName){
$FindProcessorQuery = "select SMS_G_System_PROCESSOR.Name from SMS_R_System inner join SMS_G_System_PROCESSOR on SMS_G_System_PROCESSOR.ResourceId = SMS_R_System.ResourceId inner join SMS_G_System_SYSTEM on
SMS_G_System_SYSTEM.ResourceId = SMS_R_System.ResourceId where SMS_G_System_SYSTEM.Name = '$ComputerName'"
$FindProcessorSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindProcessorQuery | Select-Object -ExpandProperty Name
$Model = Get-SCCMFindModelQuery $ComputerName
Switch -Wildcard($Model){
"Optiplex*" {
Switch -Wildcard($FindProcessorSCCM){
"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-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"}
}
}

386
Private/SHSPrinter.ps1 Normal file
View file

@ -0,0 +1,386 @@
# other powershell snmp information
# https://solvedbypowershell.blogspot.com/2014/12/powershell-using-snmp-for-html-network.html
# https://www.powershellgallery.com/packages/Proxx.SNMP/1.0.1.2/Content/Invoke-SnmpGet.ps1
# https://www.powershellgallery.com/packages/Proxx.SNMP/1.0.0.1/Content/Invoke-SnmpWalk.ps1
# https://exchange.nagios.org/directory/Plugins/Hardware/Printers/SNMP-Printer-Check/details
# https://www.powershellgallery.com/packages/Proxx.SNMP/1.1.1.4
# https://www.reddit.com/r/PowerShell/comments/77ls36/printer_page_counter_from_print_server/
# https://gallery.technet.microsoft.com/Get-PrintStatistics-a6bb8323
# https://gallery.technet.microsoft.com/scriptcenter/Script-to-generate-print-84bdcf69
function Get-SHSPrinter {
param (
[string[]]$printers
)
begin {
$snmp = New-Object -ComObject olePrn.OleSNMP
}
process {
foreach ($printer in $printers) {
#Gets the printer ip and full domain name
$result = Get-PrinterIP $printer
#CMDB Data
$cmdbRecord = Get-LANDeskCMDBItem -Name $printer
if ($cmdbRecord.values._SHSLocation3.Length -gt $cmdbRecord.values._SHSCalcLocationString.Length) {
$locationData = $cmdbRecord.values._SHSLocation3
}
else {
$locationData = $cmdbRecord.values._SHSCalcLocationString
}
if ($cmdbRecord) {
$CMDB_POA = $cmdbRecord.values._SHSPOANumber
$CMDB_AssetTag = $cmdbRecord.values._SHSAssetTag
$CMDB_Location = $locationData
$CMDB_MAC = $cmdbRecord.values._SHSMACAddress
$CMDB_model = $cmdbRecord.values._Model
$CMDB_serial = $cmdbRecord.values._SerialNumber
$CMDB_IP = $cmdbRecord.values._IPAddress
}
else {
$CMDB_POA = "*CMDB Mismatch - check CMDB*"
$CMDB_AssetTag = "*CMDB Mismatch - check CMDB*"
$CMDB_Location = "*CMDB Mismatch - check CMDB*"
$CMDB_MAC = "*CMDB Mismatch - check CMDB*"
$CMDB_model = "*CMDB Mismatch - check CMDB*"
$CMDB_serial = "*CMDB Mismatch - check CMDB*"
$CMDB_IP = "*CMDB Mismatch - check CMDB*"
}
if ($null -ne $result.IP) {
$printerip = $result.IP
$domainName = $result.Path
#checks to see if the printer is online
$online = Test-Connection $printerip -ErrorAction SilentlyContinue
if ($online) {
#opens snmp connection to the printer
$snmp.open($printerip, 'public', 2, 3000)
# Start of MAC
$pMAC = $SNMP.get(".1.3.6.1.2.1.2.2.1.6.2")
$MAC = [System.Text.Encoding]::Default.GetBytes($PMac) | ForEach-Object {
$_.ToString('X2')
}
$MAC = $MAC -join ':'
#End of MAC
# MODEL
try { $model = $snmp.Get('.1.3.6.1.2.1.25.3.2.1.3.1') } catch { $model = $null }
# IF IT HAS A MODEL NAME...
if ($model) {
# COLOR
# might want to check on this one
try { if ($snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.2') -match 'Toner|Cartridge|ink') { $color = 'Yes' } else { $color = 'No' } } catch { $color = 'No' }
# TRAYS
try { $trays = $($snmp.GetTree('.1.3.6.1.2.1.43.8.2.1.13') | Where-Object { $_ -notlike 'print*' }) -join ';' } catch { $trays = $null }
# SERIAL
try { $serial = $snmp.Get('.1.3.6.1.2.1.43.5.1.1.17.1') } catch { $serial = $null }
#PAGECOUNT
try { $pagecount = $snmp.Get('.1.3.6.1.2.1.43.10.2.1.4.1.1') } catch { $page = $null }
##### FEATURES, NAME
switch -Regex ($model) {
'^sharp' {
try { $status = $snmp.Get('.1.3.6.1.2.1.43.18.1.1.8.1.1') } catch { $status = $null }
# Start of MAC
$pMAC = $SNMP.get(".1.3.6.1.4.1.11.2.4.3.1.23.0")
write-host $pMAC.ToString()
$MAC = [System.Text.Encoding]::Default.GetBytes($PMac) | ForEach-Object {
$_.ToString('X2')
}
$MAC = $MAC -join ':'
#End of MAC
}
'^zebra' {
try { $name = $snmp.Get('.1.3.6.1.4.1.10642.1.4.0').toupper() } catch { $name = $null }
try { $model = $snmp.Get('.1.3.6.1.4.1.10642.200.19.7.0').toupper() } catch { $model = $null }
try { $MAC = $snmp.Get('.1.3.6.1.4.1.10642.20.10.20.10.2.1.5.2').toupper() } catch { $MAC = $null }
try { $serial = $snmp.Get('.1.3.6.1.4.1.10642.200.19.5.0') } catch { $serial = $null }
# try { $status = $snmp.Get('.1.3.6.1.4.1.10642.200.4.1.0') } catch { $status = $null }
$model = "Zebra $model"
#STATUS
$uri = $domainName
$html = Invoke-WebRequest -uri $uri
$raw = $html.rawcontent
$raw -match '([A-Z])\w+<.F' | Out-Null
$status = ($Matches[0] -split '<')[0]
#split off error condition
$raw -match 'RED>.+' | Out-Null
$split = $Matches[0] -split '>'
$err = $split[1] -split '<'
$status = $status + ' ' + $err[0]
}
'^lexmark' {
try { $name = $snmp.Get('.1.3.6.1.4.1.641.1.5.7.6.0').toupper() } catch { $name = $null }
}
'^ricoh' {
try { $name = $snmp.Get('.1.3.6.1.4.1.367.3.2.1.7.3.5.1.1.2.1.1').toupper() } catch { $name = $null }
}
'^hp' {
try { $name = $snmp.Get('.1.3.6.1.4.1.11.2.4.3.5.46.0').toupper() } catch { $name = $null }
try { $status = $snmp.Get('.1.3.6.1.4.1.11.2.3.9.1.1.3.0') } catch { $status = $null }
if ($MAC -eq '') {
$pMAC = $snmp.Get('.1.3.6.1.4.1.11.2.4.3.1.12.1.2.5')
$MAC = ($pMAC -split " ")[-1]
$MAC = ($MAC -replace '(..)', '$1:').trim(':')
}
#TONER
<#
HP Maintenance Kit Cur: 1.3.6.1.2.1.43.11.1.1.9.1.2
HP Maintenance Kit Max: 1.3.6.1.2.1.43.11.1.1.8.1.2
HP Toner Cur: 1.3.6.1.2.1.43.11.1.1.9.1.1
HP Toner Max: 1.3.6.1.2.1.43.11.1.1.8.1.1
#>
try { $tonerColor = ($snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.1') -split ' ')[0] } catch { $tonerColor = $null }
try { $tonerLvl = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.9.1.1') } catch { $tonerLvl = $null }
try { $tonerMax = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.8.1.1') } catch { $tonerMax = $null }
try { $toner = $tonerLvl / $tonerMax } catch { $toner = $null }
[int]$toner = $toner * 100
$supplies = "$tonerColor" + ":$toner% "
if ($color -eq 'Yes') {
try { $tonerColor = ($snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.2') -split ' ')[0] } catch { $tonerColor = $null }
try { $tonerLvl = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.9.1.2') } catch { $tonerLvl = $null }
try { $tonerMax = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.8.1.2') } catch { $tonerMax = $null }
try { $toner = $tonerLvl / $tonerMax * 100 } catch { $toner = $null }
$supplies += "$tonerColor" + ":$toner% "
try { $tonerColor = ($snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.3') -split ' ')[0] } catch { $tonerColor = $null }
try { $tonerLvl = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.9.1.3') } catch { $tonerLvl = $null }
try { $tonerMax = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.8.1.3') } catch { $tonerMax = $null }
try { $toner = $tonerLvl / $tonerMax * 100 } catch { $toner = $null }
$supplies += "$tonerColor" + ":$toner% "
try { $tonerColor = ($snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.4') -split ' ')[0] } catch { $tonerColor = $null }
try { $tonerLvl = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.9.1.4') } catch { $tonerLvl = $null }
try { $tonerMax = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.8.1.4') } catch { $tonerMax = $null }
try { $toner = $tonerLvl / $tonerMax * 100 } catch { $toner = $null }
$supplies += "$tonerColor" + ":$toner% "
try { $supplyName = ($snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.6') -split ' ')[0] } catch { $tonerColor = $null }
if ($supplyName -contains 'Fuser' -or $supplyName -contains 'Maint') {
try { $supplyPartNumber = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.6') } catch { $supplyPartNumber = $null }
$supplyPartNumber -match '110V-(?<Name>.+), ' | Out-Null
$supplyPartNumber = $Matches.Name
try { $mainLvl = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.9.1.6') } catch { $mainLvl = $null }
try { $mainMax = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.8.1.6') } catch { $mainMax = $null }
if ($mainMax -gt 1) {
try { $maintKit = $mainLvl / $mainMax } catch { $maintKit = $null }
[int]$maintKit = $maintKit * 100
if ($null -ne $maintKit) {
$supplies += "| $supplyName" + ":$maintKit%[$supplyPartNumber]"
}
}
}
else {
try { $supplyName = ($snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.5') -split ' ')[1] } catch { $tonerColor = $null }
try { $supplyPartNumber = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.5') } catch { $supplyPartNumber = $null }
$supplyPartNumber -match '110V-(?<Name>.+), ' | Out-Null
$supplyPartNumber = $Matches.Name
try { $mainLvl = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.9.1.5') } catch { $mainLvl = $null }
try { $mainMax = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.8.1.5') } catch { $mainMax = $null }
if ($mainMax -gt 1) {
try { $maintKit = $mainLvl / $mainMax } catch { $maintKit = $null }
[int]$maintKit = $maintKit * 100
if ($null -ne $maintKit) {
$supplies += "| $supplyName" + ":$maintKit%[$supplyPartNumber]"
}
}
}
}
else {
try { $supplyName = ($snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.2') -split ' ')[0] } catch { $supplyName = $null }
try { $supplyPartNumber = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.2') } catch { $supplyPartNumber = $null }
$supplyPartNumber -match '110V-(?<Name>.+), ' | Out-Null
$supplyPartNumber = $Matches.Name
try { $mainLvl = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.9.1.2') } catch { $mainLvl = $null }
try { $mainMax = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.8.1.2') } catch { $mainMax = $null }
if ($mainMax -gt 1) {
try { $maintKit = $mainLvl / $mainMax } catch { $maintKit = $null }
[int]$maintKit = $maintKit * 100
if ($null -ne $maintKit) {
$supplies += "| $supplyName" + ":$maintKit%[$supplyPartNumber]"
}
}
}
}
'^muratec' {
try { $name = $snmp.Get('.1.3.6.1.4.1.11.2.4.3.5.46.0').toupper() } catch { $name = $null }
try { $status = $snmp.Get('.1.3.6.1.2.1.43.16.5.1.2.1.1') } catch { $status = $null }
# Start of MAC
$pMAC = $SNMP.get('.1.3.6.1.4.1.4322.101.1.2.1.5.2.1.1.3.1')
Write-Host $pMAC
$MAC = [System.Text.Encoding]::Default.GetBytes($PMac) | ForEach-Object {
$_.ToString('X2')
}
$MAC = $MAC -join ':'
#End of MAC
}
default {
}
}
#if ($model -like 'SHARP*') {}
}
}
else {
$status = "Offline"
$MAC = $CMDB_MAC
$model = $CMDB_model
$serial = $CMDB_serial
$color = "Offline"
$trays = "Offline"
$pagecount = "Offline"
}
$props = [Ordered]@{
Machine = $printer
Status = $status
IP = $printerip
DomainName = $domainName
MAC = $MAC
Model = $model
Serial = $serial
#Comment = $comment
Color = $color
Trays = $trays
#Features = $features
#SystemDescription = $sysdescr0
#Addresses = $addr
PageCount = $pagecount
Supplies = $supplies
'CMDB POA' = $CMDB_POA
'CMDB AssetTag' = $CMDB_AssetTag
'CMDB Location' = $CMDB_Location
}
$obj = New-Object -TypeName PSObject -Property $props
$snmp.close()
return $obj
}
}
if ($CMDB_IP) {
$offlineIP = 'CMDB IP - ' + $CMDB_IP
}
else {
$offlineIP = 'No DNS Entry'
}
$props = [Ordered]@{
Machine = $printer
Status = 'No DNS Entry'
IP = $offlineIP
DomainName = 'No DNS Entry'
MAC = $CMDB_MAC
Model = $CMDB_model
Serial = $CMDB_serial
#Comment = $comment
Color = 'No DNS Entry'
Trays = 'No DNS Entry'
PageCount = 'No DNS Entry'
'CMDB POA' = $CMDB_POA
'CMDB AssetTag' = $CMDB_AssetTag
'CMDB Location' = $CMDB_Location
}
$obj = New-Object -TypeName PSObject -Property $props
$snmp.close()
return $obj
}
}
function Get-PrinterIP {
param (
[parameter(ValueFromPipeline)]
[string]$printer
)
$hit = $false
$domains = @('.gsrmc.int.samhealth.net', '.avery.int.samhealth.net', '.sagh.int.samhealth.net', '.snlh.int.samhealth.net', '.slch.int.samhealth.net', '.spch.int.samhealth.net')
$result = Resolve-DnsName $printer -ErrorAction SilentlyContinue
if ($null -eq $result) {
$hit = $false
foreach ($domain in $domains) {
$search = "$printer$domain"
$result = Resolve-DnsName $search -ErrorAction SilentlyContinue
if ($null -ne $result) {
$hit = $true
$name = $result.Name
$ip = $result.IPAddress
}
}
if ($null -eq $result) {
if ($hit -eq $false) {
$ip = $null
$name = $null
}
}
}
else {
$name = $result.Name
$ip = $result.IPAddress
}
$props = [ordered]@{Hostname = $printer
IP = $ip
Path = $name
}
$obj = New-Object -TypeName PSObject -Property $props
return $obj
}
function Start-SHSPrinterWeb {
param(
$printer
)
process {
if ($printer.DomainName -ne 'No DNS Entry' -and $printer.MAC -ne 'Offline') {
$domainName = $printer.DomainName
Start-Process "http://$domainName"
$mac = $printer.MAC
Start-Sleep -Seconds 1
Start-Process "https://shsorion/Orion/UDT/EndpointDetails.aspx?NetObject=UE-MAC:VAL=$mac"
}
else {
Write-Warning "Unable to launch web interface"
}
}
}

66
Private/SHSUser.ps1 Normal file
View file

@ -0,0 +1,66 @@
function Get-SHSUser {
param (
[parameter(ValueFromPipeline)]
[string]$user
)
if($null -eq (get-module -ListAvailable -Name 'ActiveDirectory')){
Write-Warning 'Active Drirectory Thick Client is required for this function'
return
}
if($user -match "^[\d\.]+$"){
$UserInfo = Get-ADUser -Filter { EmployeeID -eq $user } -properties *
$user = $UserInfo.SamAccountName
}
if($user -match "\w \w"){
$UserInfo = Get-ADUser -Filter { DisplayName -eq $user } -Properties *
$user = $UserInfo.SamAccountName
}
else {
$UserInfo = Get-ADUser -Identity $user -Properties *
}
if($null -eq $UserInfo){
$props = [ordered]@{
Name="User does not exist in AD"
UserName=$null
EmployeeID=$null
Title=$null
Department=$null
Manager=$null
Phone=$null
Email=$null
Computers=$null
}
$obj = New-Object -TypeName PSObject -Property $props
return $obj
}
$manager = $UserInfo.Manager.Split("=,")[1]
$SiteName="100"
$SCCMServer="shscm01.int.samhealth.net"
$SCCMNameSpace="root\sms\site_100"
$SCCMUserQuery = "select distinct SMS_R_System.Name from SMS_R_System where SMS_R_System.LastLogonUserName = '$user'"
$computerSCCM = Get-WmiObject -namespace $SCCMNameSpace -DirectRead -computer $SCCMServer -query $SCCMUserQuery | Select-Object -ExpandProperty Name
$computerList = $computerSCCM -join ", "
$props = [ordered]@{
Name=$UserInfo.DisplayName
UserName=$user
EmployeeID=$UserInfo.EmployeeID
Title=$UserInfo.Title
Department=$UserInfo.Department
Manager=$manager
Phone=$UserInfo.telephoneNumber
Email=$UserInfo.EmailAddress
Computers=$computerList
}
$obj = New-Object -TypeName PSObject -Property $props
return $obj
}

124
Private/Search-CMDB.ps1 Normal file
View file

@ -0,0 +1,124 @@
function Search-CMDB{
[CmdletBinding()]
param (
[Parameter(HelpMessage = 'Search LANDesk CMDB by the Name of the CMDM Item'
)]
[string]$Hostname,
[Parameter(HelpMessage = 'Search for the CMDB Item by Asset Tag Number'
)]
[string]$AssetTag,
[Parameter(HelpMessage = 'Search for the CMDB Item by Location'
)]
[string]$Location,
[Parameter(HelpMessage = 'Search for the CMDB Item by Guid/Key'
)]
[string]$key,
[Parameter(HelpMessage = 'Specifying Server',
Mandatory = $false,
DontShow = $true)]
[string] $server = $(Connect-LANDesk)[1],
[Parameter(HelpMessage = 'Specifying LanDesk Framework for api',
Mandatory = $false,
DontShow = $true)]
[string] $framework = $(Connect-LANDesk)[2],
[Parameter(HelpMessage = 'Specifying LanDesk Headers for api',
Mandatory = $false,
DontShow = $true)]
[hashtable] $Headers = $(Connect-LANDesk)[0]
)
if(($Hostname + $AssetTag + $Location + $key) -eq ''){
Write-Warning 'Input cannot be null'
return
}
$attributes = @(
'Guid',
'Title',
'_ConfigTypesCategory',
'Status',
'_SHSAssetTag',
'_SerialNumber',
'_Model',
'ConfigurationItem',
'ConfigurationItem.Guid',
'ConfigurationItem._SHSDELAsset',
'ConfigurationItem._SHSVendorPC',
'CreationDate',
'CreationUser',
'LastUpdate',
'LastUpdateUser',
'Lifecycle',
'_LocationDetails',
'_SHSLocation3',
'_SHSCINotes',
'_SHSCIPrimaryOwner',
'_SHSSCCMScanDate',
'_SHSChassisType',
'_SHSPOANumber'
)
$attributesString = $attributes -join ','
$uri = 'http://' + $server + '/' + $framework + '/api/'
$searchUri = $uri + 'query/?class_name=_CMDBManagement.Call&page_size=20000000&attributes=' + $attributesString + '&v=*' + '&cns=' + '_SHSDeleted-e-0_a_' + 'Title' + '-c-1_a_' + '_SHSLocation3' +'-c-2-&c0=False&c1=' + $Hostname + '&c2=' + $Location
$SearchResults = (Invoke-RestMethod -Uri $searchUri -Headers $headers -Method get).DataRows
$output = @()
if($SearchResults -is [array]){
foreach($result in $SearchResults){
$cmdbRecord = [PSCustomObject]@{
Hostname = $result.values.Title
AssetTag = $result.values._SHSAssetTag
Status = $result.values.Status
Type = $result.values._ConfigTypesCategory
Model = $result.values._Model
Chassis = $result.values._SHSChassisType
SerialNumber = $result.values._SerialNumber
POA = $result.values._SHSPOANumber
Location = $result.values._SHSLocation3
CreationDate = $result.values.CreationDate
CreationUser = $result.values.CreationUser
LastUpdate = $result.values.LastUpdate
LastUpdateUser = $result.values.LastUpdateUser
Lifecycle = $result.values.Lifecycle
Guid = $result.Key
CI = $result.values.ConfigurationItem
}
$output += $cmdbRecord
}
}
else{
$output = [PSCustomObject]@{
Hostname = $SearchResults.values.Title
AssetTag = $SearchResults.values._SHSAssetTag
Status = $SearchResults.values.Status
Type = $SearchResults.values._ConfigTypesCategory
Model = $SearchResults.values._Model
Chassis = $SearchResults.values._SHSChassisType
SerialNumber = $SearchResults.values._SerialNumber
POA = $SearchResults.values._SHSPOANumber
Location = $SearchResults.values._SHSLocation3
CreationDate = $SearchResults.values.CreationDate
CreationUser = $SearchResults.values.CreationUser
LastUpdate = $SearchResults.values.LastUpdate
LastUpdateUser = $SearchResults.values.LastUpdateUser
Lifecycle = $SearchResults.values.Lifecycle
Guid = $SearchResults.Key
CI = $SearchResults.values.ConfigurationItem
}
}
return $output | Select-Object -Property Hostname, Type, Location
}

View file

@ -0,0 +1,23 @@
Function Get-ServiceTagConversion($ComputerName){
$SiteName="100"
$SCCMServer="shscm01.int.samhealth.net"
$SCCMNameSpace="root\sms\site_100"
#Set Service Tag to $comp
$ServiceTagSCCM = $ComputerName
$SCCMQuery = "select SMS_R_System.Name from SMS_R_System inner join SMS_G_System_SYSTEM_ENCLOSURE on
SMS_G_System_SYSTEM_ENCLOSURE.ResourceId = SMS_R_System.ResourceId where SMS_G_System_SYSTEM_ENCLOSURE.SerialNumber = '$ServiceTagSCCM'"
#Set $comp to find hostname of PC
$nameHolder = Get-WmiObject -namespace $SCCMNameSpace -DirectRead -computer $SCCMServer -query $SCCMQuery | Select-Object -First 1 -ExpandProperty Name
if($null -ne $nameHolder)
{
$ComputerName = $nameHolder
return $ComputerName
}
}

View file

@ -0,0 +1,368 @@
function Set-CMDBLocation {
[CmdletBinding()]
param (
[Parameter()]
[string]
$Hostname
)
process {
try { $cmdbData = Get-LANDeskCMDBItem -Name $Hostname } catch { $cmdbData = $null}
if($null -eq $cmdbData){
$getpcData = Get-PCBatchInvoke $Hostname
$asset = $getpcData.'Asset Tag'
$asset = $asset -split ' '
$asset = $asset[0]
try { $cmdbData = Get-LANDeskCMDBItem -AssetTag $asset} catch{ $cmdbData = $null }
if($null -eq $cmdbData){
Write-Warning "Unable to find record with that hostname or assset tag in CMDB"
return
}
}
$oldLocation = $cmdbData.Values._SHSLocation3
$key = $cmdbData.key
Write-Host "Hostname: $hostname"
Write-Host "Current Location: $oldLocation"
$newLocation = Read-Host "New Location"
try {Set-LANDeskCMDBWorkstation -LocationDetails $newLocation -Key $key | Out-Null }
catch {
Write-Warning "Unable to change location data"
return
}
try { $cmdbData = Get-LANDeskCMDBItem -Name $Hostname } catch { $cmdbData = $null}
if($null -eq $cmdbData){
try { $cmdbData = Get-LANDeskCMDBItem -AssetTag $asset} catch{ $cmdbData = $null }
if($null -eq $cmdbData){
Write-Warning "Unable to find record with that hostname or assset tag in CMDB"
return
}
}
$newLocation = $cmdbData.values._SHSLocation3
Write-Host "Location now set to: $newLocation" -ForegroundColor Green
}
}
function Set-LANDeskCMDBLocation {
[CmdletBinding(DefaultParameterSetName="Default")]
param (
[Parameter(HelpMessage = 'The Name of the new CMDB item',
Mandatory = $true
)]
[string]$Name,
[Parameter(HelpMessage = 'Enter the Location Details for the CMDB Item')]
[string]$LocationDetails,
[Parameter(HelpMessage = 'Enter the GUID for the CMDB Item')]
[string]$Key,
[Parameter(HelpMessage = 'Specifying Server',
Mandatory = $false,
DontShow = $true)]
[string] $server = $(Connect-LANDesk)[1],
[Parameter(HelpMessage = 'Specifying LanDesk Framework for api',
Mandatory = $false,
DontShow = $true)]
[string] $framework = $(Connect-LANDesk)[2],
[Parameter(HelpMessage = 'Specifying LanDesk Headers for api',
Mandatory = $false,
DontShow = $true)]
[hashtable] $Headers = $(Connect-LANDesk)[0]
)
begin {
}
process {
[object[]]$Values = $null
$Title = @{}
$Title.Name = "Title"
$Title.Value = $Name
[object[]]$Values += $Title
<#
$_ConfigTypesCategory = @{}
$_ConfigTypesCategory.Name = "_ConfigTypesCategory"
$_ConfigTypesCategory.Value = '9dadd9f9-ca5d-4be6-93cc-6c8745fff615'
$Values += $_ConfigTypesCategory
#>
$LocationDetails
$_SHSLocation3 = @{}
$_SHSLocation3.Name = "_SHSLocation3"
$_SHSLocation3.Value = $LocationDetails
$Values += $_SHSLocation3
$body = [ordered]@{}
$body.class_name = '_CMDBManagement.Call'
$Body.originalValues = $Values
$body.formValues = $Values
$body = $body | ConvertTo-Json
$uri = 'http://' + $server + '/' + $framework + '/api/form?class_name=_CMDBManagement.Call&key=' + $Key + '&function_name=Edit&v=*'
Invoke-RestMethod -Uri $uri -Headers $headers -Body $Body -Method Patch
}
end {
}
}
function Set-LANDeskCMDBWorkstation {
[CmdletBinding(DefaultParameterSetName="Default")]
param (
[Parameter(HelpMessage = 'The Name of the new CMDB item')]
[string]$Name,
[Parameter(HelpMessage = 'Enter the PO for the CMDB Item')]
[string]$PO,
[Parameter(HelpMessage = 'Enter the Physical Location for the CMDB Item')]
[string]$PhysicalLocation,
[Parameter(HelpMessage = 'Enter the Asset Tag for the CMDB Item')]
[string]$AssetTag,
[Parameter(HelpMessage = 'Enter the RequestID for the CMDB Item')]
[string]$RequestID,
[Parameter(HelpMessage = 'Enter the OperatingSystem for the CMDB Item')]
[string]$OperatingSystem,
[Parameter(HelpMessage = 'Enter the ChassisType for the CMDB Item')]
[string]$ChassisType,
[Parameter(HelpMessage = 'Enter the Total Hard Drive Size for the CMDB Item')]
[string]$HDD,
[Parameter(HelpMessage = 'Enter the RAM for the CMDB Item')]
[string]$RAM,
[Parameter(HelpMessage = 'Enter the Hard drive space Avalible for the CMDB Item')]
[string]$HDDAvail,
[Parameter(HelpMessage = 'Enter the IPAddress for the CMDB Item')]
[string]$IPAddress,
[Parameter(HelpMessage = 'Enter the KioskRole for the CMDB Item')]
[string]$KioskRole,
[Parameter(HelpMessage = 'Enter the Model for the CMDB Item')]
[string]$Model,
[Parameter(HelpMessage = 'Enter the SerialNumber for the CMDB Item')]
[string]$SerialNumber,
[Parameter(HelpMessage = 'Enter the Notes for the CMDB Item')]
[string]$Notes,
[Parameter(HelpMessage = 'Enter the OSPatching for the CMDB Item')]
[string]$OSPatching,
[Parameter(HelpMessage = 'Enter the Patch Schedule for the CMDB Item')]
[string]$PatchSchedule,
[Parameter(HelpMessage = 'Enter the Patch Notes for the CMDB Item')]
[string]$PatchNotes,
[Parameter(HelpMessage = 'Enter the Location Details for the CMDB Item')]
[string]$LocationDetails,
[Parameter(HelpMessage = 'Enter the GUID for the CMDB Item',
Mandatory = $true)]
[string]$Key,
[Parameter(HelpMessage = 'Specifying Server',
Mandatory = $false,
DontShow = $true)]
[string] $server = $(Connect-LANDesk)[1],
[Parameter(HelpMessage = 'Specifying LanDesk Framework for api',
Mandatory = $false,
DontShow = $true)]
[string] $framework = $(Connect-LANDesk)[2],
[Parameter(HelpMessage = 'Specifying LanDesk Headers for api',
Mandatory = $false,
DontShow = $true)]
[hashtable] $Headers = $(Connect-LANDesk)[0]
)
begin {
}
process {
[object[]]$Values = $null
if($Name){
$Title = @{}
$Title.Name = "Title"
$Title.Value = $Name
[object[]]$Values += $Title
}
<# $_ConfigTypesCategory = @{}
$_ConfigTypesCategory.Name = "_ConfigTypesCategory"
$_ConfigTypesCategory.Value = '9dadd9f9-ca5d-4be6-93cc-6c8745fff615'
$Values += $_ConfigTypesCategory #>
if ($PO) {
$_PO = @{}
$_PO.Name = "_PO"
$_PO.Value = $PO
$Values += $_PO
}
# Look up table
if ($PhysicalLocation) {
$Location = Search-LANDeskIssueLocation -Location $PhysicalLocation
$_CILocation = @{}
$_CILocation.Name = "_CILocation"
$_CILocation.Value = $Location.Key
$Values += $_CILocation
}
if ($AssetTag) {
$_SHSAssetTag = @{}
$_SHSAssetTag.Name = "_SHSAssetTag"
$_SHSAssetTag.Value = $AssetTag
$Values += $_SHSAssetTag
}
if ($RequestID) {
$_RequestID = @{}
$_RequestID.Name = "_RequestID"
$_RequestID.Value = $RequestID
$Values += $_RequestID
}
# Look up table
if ($OperatingSystem) {
if($OperatingSystem -match 'Windows 10'){
$OS = '2ad72fd5-8d4e-4510-b5ea-f94b3a2cda08'
}
elseif ($OperatingSystem -match 'Windows 7') {
$OS = 'f127ceee-074b-4cc1-8a71-f8c02a9a9bd1'
}
else {
$OS = '00000000-0000-0000-0000-000000000000'
}
$_SHSOperatingSystem = @{}
$_SHSOperatingSystem.Name = "_SHSOperatingSystem"
$_SHSOperatingSystem.Value = $OS
$Values += $_SHSOperatingSystem
}
if ($ChassisType) {
if($ChassisType -match "Desktop" -or $ChassisType -match "SFF"){
$ChassisGuid = 'c7f3c5ba-a8b3-40be-963f-7e1d75fb7fda'
}
elseif ($ChassisType -match "Micro") {
$ChassisGuid = '8d71a4c3-ae9d-4e55-98ea-2f8a75987cac'
}
elseif($ChassisType -match "Laptop"){
$ChassisGuid = 'a8460b18-bab9-4c07-8fb1-a4cca4e63fa1'
}
elseif($ChassisType -match "Tablet"){
$ChassisGuid = 'e6ae9cd4-9936-496d-8e5d-efce8417a3d0'
}
else{
$ChassisGuid = '00000000-0000-0000-0000-000000000000'
}
$_SHSChassisType = @{}
$_SHSChassisType.Name = "_SHSChasisRef"
$_SHSChassisType.Value = $ChassisGuid
$Values += $_SHSChassisType
}
if ($HDD) {
$_HardDiskSize = @{}
$_HardDiskSize.Name = "_HardDiskSize"
$_HardDiskSize.Value = $HDD
$Values += $_HardDiskSize
}
if ($RAM) {
$_RAM = @{}
$_RAM.Name = "_RAM"
$_RAM.Value = $RAM
$Values += $_RAM
}
if ($HDDAvail) {
$_AvailableDiskSpace = @{}
$_AvailableDiskSpace.Name = "_AvailableDiskSpace"
$_AvailableDiskSpace.Value = $HDDAvail
$Values += $_AvailableDiskSpace
}
if ($IPAddress) {
$_IPAddress = @{}
$_IPAddress.Name = "_IPAddress"
$_IPAddress.Value = $IPAddress
$Values += $_IPAddress
}
if ($Model) {
$_Model = @{}
$_Model.Name = "_Model"
$_Model.Value = $Model
$Values += $_Model
}
if ($SerialNumber) {
$_SerialNumber = @{}
$_SerialNumber.Name = "_SerialNumber"
$_SerialNumber.Value = $SerialNumber
$Values += $_SerialNumber
}
if ($Notes) {
$_SHSCINotes = @{}
$_SHSCINotes.Name = "_SHSCINotes"
$_SHSCINotes.Value = $Notes
$Values += $_SHSCINotes
}
# Look up table
if ($OSPatching) {
$Patch = Search-LANDeskOSPatchType -PatchType $OSPatching
$_SHSOSPatching = @{}
$_SHSOSPatching.Name = "_SHSOSPatching"
$_SHSOSPatching.Value = $Patch.Key
$Values += $_SHSOSPatching
}
#look up table
if ($PatchSchedule) {
$Schedule = Get-LANDeskPatchSchedule -PatchSchedule $PatchSchedule
$_SHSPatchSchedule = @{}
$_SHSPatchSchedule.Name = "_SHSPatchSchedule"
$_SHSPatchSchedule.Value = $Schedule
$Values += $_SHSPatchSchedule
}
if ($PatchNotes) {
$_SHSPatchNotes = @{}
$_SHSPatchNotes.Name = "_SHSPatchNotes"
$_SHSPatchNotes.Value = $PatchNotes
$Values += $_SHSPatchNotes
}
if ($LocationDetails){
$LocationDetails
$_SHSLocation3 = @{}
$_SHSLocation3.Name = "_SHSLocation3"
$_SHSLocation3.Value = $LocationDetails
$Values += $_SHSLocation3
}
$body = [ordered]@{}
$body.class_name = '_CMDBManagement.Call'
$Body.originalValues = $Values
$body.formValues = $Values
$body = $body | ConvertTo-Json
$uri = 'http://' + $server + '/' + $framework + '/api/form?class_name=_CMDBManagement.Call&key=' + $Key + '&function_name=Edit&v=*'
Invoke-RestMethod -Uri $uri -Headers $headers -Body $Body -Method Patch
}
end {
}
}

17
Private/Update-GetPC.ps1 Normal file
View file

@ -0,0 +1,17 @@
function Update-GetPC {
$GetPCSourcePath = "\\int.samhealth.net\files\TEAM\SHSISDesktopSolutions\Powershell\Get-PC_Update_2023\Prod\Get-PC\"
$desinationPath = ($env:PSModulePath -split ';')[0] + "\Get-PC"
Write-Host "Updating Get-PC..."
Robocopy.exe $GetPCSourcePath $desinationPath /mir | Out-Null
if($LASTEXITCODE -gt 7){
Write-Warning 'An error has occured during update. Please restart powershell and try again'
}
else{
Write-Host 'Update Complete: Please Restart Powershell' -ForegroundColor Green
}
}

View file

@ -0,0 +1,346 @@
function Get-UserProfileBackup($Computer) {
<#
.SYNOPSIS
Backs up a user profile.
.DESCRIPTION
Takes a input of hostname and user and will make a copy of the user profile
and the Microsoft Roaming Folder and back it up on the share drive.
#>
#Charles Beddow maintains the UserProfileBackup
#The folders that this back up file grabs
$FoldersToCopy = @(
'Desktop'
'Downloads'
'Favorites'
'Documents'
'Pictures'
'Videos'
'AppData\Local\Google\Chrome\User Data\Default\Bookmarks'
'AppData\Roaming\Microsoft'
'Sticky Notes'
)
if($Computer -eq $null){
$Computer = Read-Host -Prompt 'Enter computer name: '
}
$ConfirmUser = $null
#Collects the most recent users for options to backup
if($Computer -eq $env:COMPUTERNAME)
{
Import-Module "\\basagh\team\shsisdesktopsolutions\Powershell\Get-PC\Modules\PCLocal\PCLocal.psm1"
#Below are commands for the local PC when using "get-pc" by itself
$lastUser = Get-PCLastUserLocal
}
else {
$lastUser = Invoke-Command -ComputerName $Computer -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 }
if($lastUser -eq $null){
Write-warning "PC unreachable or no profiles to back up"
return
}
}
Write-Host "Latest Users: $lastUser"
#Asks user to pick which profile to backup
while( $ConfirmUser -eq $null ){
$User = Read-Host -Prompt 'Choose user to backup'
if( -not ( Test-Path -Path "\\$Computer\c$\Users\$User" -PathType Container ) ){
Write-Warning "$User could not be found on $Computer. Please enter another user profile."
continue
}
else {
$testPath = Resolve-Path -Path "\\$Computer\c$\Users\$User\Desktop"
if (-not $testPath ){
Write-Warning "Unable to access profile"
Write-Warning "Please try running script as Admin"
break
}
}
<#
Write-Host "Scanning user profile..."
$profileSize = scan-dir "\\$Computer\c$\Users\$User"
$sizeout = "{1} profile is {0:n3}GB" -f $profileSize,$user
Write-Host $sizeout
#>
$ConfirmUser = Read-Host -Prompt "Copy profile? (y/n) or Restore profile (r)"
if($ConfirmUser -eq 'n'){
$ConfirmUser = Read-Host -Prompt "Choose another user? (y/n)"
if($ConfirmUser -eq 'y'){
$ConfirmUser = $null
continue
}
}
}
if($ConfirmUser -eq 'n'){
Write-Host "User backup canceled"
}
#Backup Locations
$backupLocations = @()
$obj = New-Object PSObject -Property @{
Site='GSRMC'
Path="\\SHSCMGSRMC\ProfileBackup"}
$backupLocations += $obj
$obj = New-Object PSObject -Property @{
Site='SAGH'
Path="\\SHSCMSAGH\ProfileBackup"}
$backupLocations += $obj
$obj = New-Object PSObject -Property @{
Site='SNLH'
Path="\\SHSCMSNLH\ProfileBackup"}
$backupLocations += $obj
$obj= New-Object PSObject -Property @{
Site='LCH'
Path="\\shscmslch\ProfileBackup"}
$backupLocations += $obj
$obj = New-Object PSObject -Property @{
Site='Walnut'
Path="\\SHSCMWN\ProfileBackup"}
$backupLocations += $obj
$obj = New-Object PSObject -Property @{
Site='Sam Square'
Path="\\SHSCMAV\ProfileBackup"}
$backupLocations += $obj
$obj = New-Object PSObject -Property @{
Site='HP'
Path="\\SHSCM01\ProfileBackup"}
$backupLocations += $obj
$obj = New-Object PSObject -Property @{
Site='SPCH'
Path="\\SHSCMSPCH\ProfileBackup"}
$backupLocations += $obj
$obj = New-Object PSObject -Property @{
Site='Old Team Share'
Path="\\basagh\team\SHSISDesktopSolutions\General Shared Items\User Profile Backup"}
$backupLocations += $obj
$Date = Get-Date -Format "MM-dd"
$DestinationFileName = "$Computer-$User-$Date"
$SourceRoot = "\\$Computer\c$\Users\$User"
$BackupDestination = "\\SHSCMGSRMC\ProfileBackup"
$Destination = "\\SHSCMGSRMC\ProfileBackup\$DestinationFileName"
$CopiedUserDesktop = Join-Path -Path $Destination -ChildPath "Desktop"
#region BACKUP
if($ConfirmUser -eq 'y'){
#Chooses Site to Backup the profile to
Write-Host "Choose Site to backup"
for($i=0;$i -lt 8; $i++){
$out = "[{0}]: {1}" -f $i, $backupLocations[$i].Site
Write-Host $out
}
[int]$site = Read-Host "Site"
if(!(($site -ge 0 ) -and ($site -lt 8))){
Write-Warning "Invalid input please restart script"
return
}
$BackupDestination = $backupLocations[$site].Path
$Destination = "$BackupDestination\$DestinationFileName"
#Creates a backup directory named "ComputerName-User-TodaysDate"
New-Item -Path $Destination -ItemType Directory | Write-Verbose
if($User -eq "Public"){
$FoldersToCopy = @('Desktop')
}
#Creates a log file
New-Item -Path $Destination\backuplog.txt -Force | Write-Verbose
$log = Join-Path -Path $Destination -ChildPath backuplog.txt
Write-Host "Copying profile to $Destination"
foreach( $Folder in $FoldersToCopy ){
$Source = Join-Path -Path $SourceRoot -ChildPath $Folder
Write-Host "Copying $Folder"
if( $Folder -eq 'Sticky Notes'){
$Source = Join-Path -Path $SourceRoot -ChildPath 'AppData\Local\Packages\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe\LocalState'
}
#Checks if folder paths are available
if( -not ( Test-Path -Path $Source ) ){
Write-Warning "Could not find path`t$Source"
continue
}
if( -not ( Test-Path -Path $Destination -PathType Container ) ){
Write-Warning "Could not find path`t$Destination"
continue
}
if($Folder -eq 'AppData\Roaming\Microsoft'){
#If it's time to copy AppData folder it changes the copy destination to build the proper directory tree
$Destination = Join-Path -Path $Destination -ChildPath 'AppData\Roaming\Microsoft'
Copy-Item -Path (Get-Item -Path "$Source\*" -Exclude ('Teams')).FullName -Destination $Destination -Recurse -Force -PassThru | Out-File $log -Append
Write-Host 'complete'
continue
}
if ($Folder -eq 'Sticky Notes'){
$Destination = Join-Path -Path "$BackupDestination\$DestinationFileName" -ChildPath 'Sticky Notes'
}
Copy-Item $Source -Destination $Destination -Recurse -PassThru | Out-File $log -Append
Write-Host "complete"
}
#Cleans up Citrix Shortcuts
Write-Host "Removing Citrix Shortcuts from backup"
$Shortcuts = Get-ChildItem -Path $CopiedUserDesktop -Filter *.lnk
foreach($Shortcut in $Shortcuts){
$sh = New-Object -ComObject WScript.Shell
if($sh.CreateShortcut($Shortcut.FullName).TargetPath -eq 'C:\Program Files (x86)\Citrix\ICA Client\SelfServicePlugin\SelfService.exe') {
Remove-Item $Shortcut.FullName
}
}
Write-Host "Complete"
}
#endregion
#region RESTORE
if($ConfirmUser -eq 'r'){
$backups = @()
foreach($b in $backupLocations) {
$paths = @()
$paths += Get-ChildItem -Path $b.Path -Name -Filter "*$User*"
foreach($p in $paths){
$obj = New-Object PSObject -Property @{
File = $p
Location = $b.Path
}
$backups += $obj
}
}
if($null -eq $backups[0]){
Write-Warning "no backups available for this user"
return
}
else{
Write-Host "These backups are available for this user:"
}
if($backups -is [array]) {
$i = 0
foreach ($backup in $backups){
$out = $backup.File
Write-Host "[$i] $out"
$i++
}
$FileToRestoreIndex = Read-Host -Prompt "Please type which directory you'd like to restore"
$FileToRestore = $backups[$FileToRestoreIndex].File
$BackupDestination = $backups[$FileToRestoreIndex].Location
}
else{
$out = $backups.File
Write-Host "[0] $out"
$FileToRestoreIndex = Read-Host -Prompt "Please confirm which directory you'd like to restore"
if($FileToRestoreIndex -eq 0){
$FileToRestore = $backups.File
$BackupDestination = $backups.Location
}
}
Write-Host "Restoring $FileToRestore"
Write-Host "--------------------"
$FullRestorationSource = Join-Path -Path $BackupDestination -ChildPath $FileToRestore
Write-Verbose $FullRestorationSource
if( -not ( Test-Path -Path $FullRestorationSource -PathType Container ) ){
Write-Warning "The backup you have chosen does not exist"
break
}
if($User -eq "Public"){
$FoldersToCopy = @('Desktop')
}
foreach( $Folder in $FoldersToCopy ){
#Special Case for AppData
if($Folder -eq 'AppData\Roaming\Microsoft'){
$Folder = 'AppData'
}
$CurrentRestoreFolder = Join-Path -Path $FullRestorationSource -ChildPath $Folder
#Special Case for Google Bookmarks
if($Folder -eq 'AppData\Local\Google\Chrome\User Data\Default\Bookmarks'){
Write-Host "Restoring Chrome Bookmarks"
if( -not ( Test-Path -Path $FullRestorationSource\Bookmarks)){
Write-Host "No Chrome Bookmarks backup"
continue
}
if( -not ( Test-Path -Path "$SourceRoot\AppData\Local\Google\Chrome")){
Write-Warning "Restoring Chrome bookmarks but Chrome is not installed on this machine"
}
if( -not ( Test-Path -Path "$SourceRoot\AppData\Local\Google\Chrome\User Data\Default")){
New-Item "$SourceRoot\AppData\Local\Google\Chrome\User Data\Default" -ItemType Container | Write-Verbose
}
Copy-Item $FullRestorationSource\Bookmarks -Destination "$SourceRoot\AppData\Local\Google\Chrome\User Data\Default\Bookmarks" -Force
Write-Host "complete"
continue
}
#Special Case for Sticky Notes
if($Folder -eq 'Sticky Notes'){
continue
}
Write-Host "Restoring $Folder"
#Checks if folder paths are available
if( -not ( Test-Path -Path $CurrentRestoreFolder -PathType Container ) ){
Write-Warning "Could not find path`t$Source"
continue
}
if( -not ( Test-Path -Path $SourceRoot -PathType Container ) ){
Write-Warning "Could not find path`t$Destination"
continue
}
Copy-Item $CurrentRestoreFolder -Destination $SourceRoot -Recurse -Force
Write-Host "complete"
}
}
#endregion
}#End Function
#Helper Function
function scan-dir($Path) {
if ( (Test-Path $Path) -and (Get-Item $Path).PSIsContainer ){
$DirectorySize = (Get-ChildItem -Path $path -File -Recurse -Force -ErrorAction SilentlyContinue |
Measure-Object -Property Length -Sum).Sum / 1GB
Return $DirectorySize
}
}

33
Private/ViewerRemote.ps1 Normal file
View file

@ -0,0 +1,33 @@
Function Get-ViewerRemote($ComputerName){
if(!(Test-Connection -ComputerName $ComputerName -Count 1))
{
Write-Host "Exiting Viewer Remote...No connection made to [$ComputerName]" -ForegroundColor Red
break
}
$SiteName = "100"
$RemoteViewerPath = "C:\Program Files (x86)\ConfigMgr\bin\i386\CmRcViewer.exe"
$RemoteViewerPathAdd = "C:\Program Files (x86)\ConfigMgr Console\bin\i386\CmRcViewer.exe"
$RemoteViewerPathAdd2 = "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\i386\CmRcViewer.exe"
if(Test-Path $RemoteViewerPath)
{
Write-Host "Attempting to remote into [$ComputerName]..." -ForegroundColor Green
Start $RemoteViewerPath $ComputerName
}elseif(Test-Path $RemoteViewerPathAdd)
{
Write-Host "Attempting to remote into [$ComputerName]..." -ForegroundColor Green
Start $RemoteViewerPathAdd $ComputerName
}elseif(Test-Path $RemoteViewerPathAdd2)
{
Write-Host "Attempting to remote into [$ComputerName]..." -ForegroundColor Green
Start $RemoteViewerPathAdd2 $ComputerName
}else{
Write-Host "`nRemote Viewer Install Path Not Found...`nPlease install Config Manager Thick Client" -ForegroundColor Red
}
}

View file

@ -0,0 +1,249 @@
Function Get-WinProfileRebuild($ComputerName) {
Write-Host "`n"
$AllUsers = 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 10 -ExpandProperty Name }
Write-Host "User Profiles Found (Only displaying newest 10 profiles): $AllUsers"
Write-Host "`nThis utility will recreate the user's Windows profile.`nThe profile folder will be preserved and renamed to 'username.backup'`n"
$UserProfile = Read-Host "Enter Username to recreate Windows user profile"
$restore = Read-Host "Confirm Rebuild(y/n) or restore(r)"
if ($restore -eq 'r') {
Invoke-WinProfileRebuildRestore -Username $UserProfile -Computername $ComputerName
return
}
elseif ($restore -ne 'y') {
Write-Host "Canceling WinProfileRebuild..." -ForegroundColor Yellow
return
}
$UserSid = get-wmiobject -computername $ComputerName -class win32_userprofile | select-object -property sid, localpath |
where-object -property localpath -EQ "C:\Users\$UserProfile" | select-object -expandproperty sid
$path = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\$UserSid"
$UserName = (Get-CimInstance -Class win32_computersystem -ComputerName $ComputerName).UserName
if ($UserProfile -eq $env:USERNAME) {
Write-Host "You cannot rebuild your own user profile..." -ForegroundColor Yellow
Return
}
if ($null -ne $UserName) {
if ($UserName -eq $UserProfile) {
$IsUserNameNotEmpty = 0 #Target user is currently logged in
}
elseif ($UserName -eq $env:USERNAME) {
$IsUserNameNotEmpty = 1 #Can rebuild if you are the one logged into the computer
}
else {
$IsUserNameNotEmpty = 1 #Other user logged in
}
}
else {
$IsUserNameNotEmpty = 1 #No User is logged in
}
if ($null -ne $UserSid) {
$IsSIDNotEmpty = 0 #User Sid exists
}
else {
$IsSIDNotEmpty = 1 #User Sid not found
}
Switch ($IsUserNameNotEmpty) {
0 {
Write-Host "`n$UserName is currently logged in, please have them logout..." -ForegroundColor Yellow
Write-Host "`n`nScript will now exit, please retry once user has logged off...`n" -ForegroundColor Yellow
Return
}
1 {
Write-Host "Proceed in rebuilding user profile..." -ForegroundColor Yellow
Pause
Break
}
Default {
Write-Host "ERROR WinProfileRebuild.psm1 Line 74" -ForegroundColor Red
Pause
Return
}
}
Switch ($IsSIDNotEmpty) {
0 {
$GetTime = Get-Date -Format "MMddHHmmss"
Invoke-Command -ComputerName $ComputerName -SessionOption (New-PSSessionOption -NoMachineProfile) -ScriptBlock {
Rename-Item -Path "C:\Users\$Using:UserProfile" -NewName "$Using:UserProfile.backup.$Using:GetTime" -Force -Verbose
#Write-Host "C:\Users\$Using:UserProfile"
if (Test-Path "C:\Users\$Using:UserProfile.backup.$Using:GetTime" ) {
Write-Host "Rename Successful" -ForegroundColor Green
}
else {
Write-Host "File rename failed. Please manually rename folder if registry removal succeeds" -ForegroundColor Red
}
Remove-Item $Using:path
Write-Host "$Using:UserProfile removed from registry..."
Write-Host "User can now relog into the workstation."
Break
}
}
1 {
Write-Host "`nUser SID ID not found in the registry..." -ForegroundColor Red
Write-Host "`n`nScript will now exit...`n" -ForegroundColor Yellow
Return
}
Default {
Write-Host "ERROR WinProfileRebuild.psm1 Line 116" -ForegroundColor Red
Pause
Break
}
}
}
function Invoke-WinProfileRebuildRestore {
param (
$Username,
$Computername
)
$FoldersToCopy = @(
'Desktop'
'Downloads'
'Favorites'
'Documents'
'Pictures'
'Videos'
'AppData\Local\Google\Chrome\User Data\Default\Bookmarks'
'AppData\Roaming\Microsoft'
)
#Find Backup folders
$backups = Get-ChildItem -Path "\\$Computername\c$\Users" | Where-Object -FilterScript { $_ -match $Username }
Write-Host "Backups"
if ($null -eq $backups) {
Write-Host "No backups for $username"
return
}
if ($backups -is [array]) {
for ($i = 0; $i -lt $backups.Count; $i++) {
$out = "[{0}] {1}" -f $i, $backups[$i]
Write-Host $out
}
$backupChoice = Read-Host "Choose which backup"
$backupChoice = [int]$backupChoice
if (($backupChoice -gt -1) -and ($backupChoice -lt $backups.Length)) {
$backup = $backups[$backupChoice]
}
else {
Write-Warning "Invalid Choice - re-run winprofile rebuild to try again"
return
}
}
else {
$out = "[{0}] {1}" -f 0, $backups
Write-Host $out
$backupChoice = Read-Host "Choose which backup"
if ($backupChoice -eq 0) {
$backup = $backups
}
else {
Write-Warning "Invalid Choice - re-run winprofile rebuild to try again"
return
}
}
Write-Host "Restoring from $backup"
$destinationPath = "\\$Computername\c$\Users\$username"
$sourcePath = "\\$Computername\c$\Users\$backup"
Write-Host "Removing Citrix Shortcuts from backup"
$CopiedUserDesktop = "$sourcePath\Desktop"
$Shortcuts = Get-ChildItem -Path $CopiedUserDesktop -Filter *.lnk
foreach ($Shortcut in $Shortcuts) {
$sh = New-Object -ComObject WScript.Shell
if ($sh.CreateShortcut($Shortcut.FullName).TargetPath -eq 'C:\Program Files (x86)\Citrix\ICA Client\SelfServicePlugin\SelfService.exe') {
Remove-Item $Shortcut.FullName
}
}
foreach ( $Folder in $FoldersToCopy ) {
$source = Join-Path $sourcePath $Folder
<#
#Special Case for Google Bookmarks
if($Folder -eq 'AppData\Local\Google\Chrome\User Data\Default\Bookmarks'){
Write-Host "Restoring Chrome Bookmarks"
if( -not ( Test-Path -Path $source)){
Write-Host "No Chrome Bookmarks backup"
continue
}
if( -not ( Test-Path -Path "$sourcePath\AppData\Local\Google\Chrome")){
Write-Warning "Restoring Chrome bookmarks but Chrome is not installed on this machine"
}
if( -not ( Test-Path -Path "$sourcePath\AppData\Local\Google\Chrome\User Data\Default")){
New-Item "$destinationPath\AppData\Local\Google\Chrome\User Data\Default" -ItemType Container | Write-Verbose
}
Copy-Item -Path $source -Destination $destinationPath -Force -Recurse
Write-Host "complete"
continue
} #>
if ((Test-Path $source) -and (Test-Path $destinationPath)) {
Write-Host "Restoring $folder "
Copy-Item -Path $source -Destination $destinationPath -Force -Recurse
}
else {
Write-Warning "Path Unreachable"
}
}
}

611
Public/Get-PC.ps1 Normal file
View file

@ -0,0 +1,611 @@
#Filename: Get-PC.ps1
#This is the primary function for get-pc. All functionality is accessed through this function
#See documentation for how to use this module
#region Module Import Block
$ErrorActionPreference = 'SilentlyContinue'
#DevStage can take either Dev or Prod as values
$devStage = 'Dev'
#Locations for dev build and prod build
$getPCDevBuildPath = '\\int.samhealth.net\files\TEAM\SHSISDesktopSolutions\Powershell\Get-PC_Update_2023\Prod\Get-PC\Get-PC.psd1'
$getPCProdBuildPath = "\\shscm01\packages\SHS Custom\Get-PC\Prod\Get-PC\Get-PC.psd1"
#grabs the version number out of the module manifest and compares it to the current production version
$modulemanifest = Join-Path (get-item $PSScriptRoot).Parent.FullName 'Get-PC.psd1'
$Version = (Test-ModuleManifest $modulemanifest).version
if ($devStage -eq "Prod") {
$deployedVersion = (Test-ModuleManifest $getPCProdBuildPath).Version
}
elseif ($devStage -eq "Dev") {
$deployedVersion = (Test-ModuleManifest $getPCDevBuildPath).Version
}
#lets user know when get-pc has been imported and what version they are running
Write-Host "`nGet-PC Module Version $Version [$devStage] Loaded." -ForegroundColor Green
if ($Version -ne $deployedVersion) {
Write-Host 'New version of Get-PC is available. Please run Get-PC -Update' -ForegroundColor Yellow
}
Write-Host "Enter 'Help Get-PC' for available commands.`n" -ForegroundColor Green
#endregion
Function Get-PC {
<#
.Synopsis
Get-PC is a custom Powershell module that contains many useful features for querying details about workstations and also performing many useful/common functions on those computers remotely.
.DESCRIPTION
Using get-pc hostname will query a workstation (or multiple workstations, comma separated) for information such as model, SSO client, currently logged in user, OS version, RAM, installed printers, etc
Expanded functionality can be accessed using these flags
-Apps | shows the installed applications on the computer
-AppDiff | shows the installed applications that are not in the standard image
-Bypass | used in conjuction with remote viewer will bypass user prompt
-Devices | shows connected monitors and usb devices
-EventLog | pulls up errors in the event log for the last x days
-Excel | exports collected data to csv and opens it with excel
-Filesystem | access the file system
-GPUpdate | runs a gpupdate
-InstallNet35 | installs .Net 3.5
-LogOffUser | remotely logs off user
-Orion | opens orion to the mac address of the pc
-PCCleanup | removes temp files and inactive user profiles
-PCReboot | reboots computer
-PCRename | renames computer
-RemoteDesktopApp | remote into computer using RDP
-RequestLauncher | starts request launcher
-ResetRepository | remotely resets repository
-SCCM | queries sccm for the computer information
-SHSPrinter | pulls data about a printer using snmp
-SHSPrinterweb | pulls data about a printer and opens web interface and orion
-SHSUser | get data about a user from AD, can accept username or employee number
-Tableview | output the results in a table
-Usb | shows installed usb devices
-UserProfileBackup | backups and restores user profiles
-ViewerRemote | remote into the computer using RemoteViewer
-WinProfileRebuild | rebuilds user profiles
For more detailed help please see the documentation on AppDoc
.EXAMPLE
Get-PC [Hostname], [Hostname], [Hostname]
.EXAMPLE
Get-PC [Hostname] -TableView -Apps
.EXAMPLE
Get-PC [Hostname] -FileSystem
#>
[CmdletBinding()]
param
(
[Parameter(ValueFromPipeline = $true)]
[string[]]$ComputerName = $env:COMPUTERNAME,
[Switch]$Apps,
[Switch]$AppDiff,
[Switch]$Bypass,
[switch]$Devices,
[Switch]$EventLog,
[switch]$Excel,
[Switch]$FileSystem,
[Switch]$GPUpdate,
[Switch]$HostnamesByPrinter,
[switch]$InstallNet35,
[switch]$Jobsprinters,
[Switch]$LogOffUser,
[Switch]$NextPrinterName,
[switch]$Orion,
[Switch]$PatchNotes,
[Switch]$PCCleanup,
[Switch]$PCReboot,
[Switch]$PCRename,
[Switch]$RemoteDesktopApp,
[Switch]$RequestLauncher,
[Switch]$Resources,
[Switch]$ResetRepository,
[Switch]$SCCM,
[Switch]$SHSPrinter,
[switch]$SHSPrinterWeb,
[Switch]$SHSUser,
[Switch]$TableView,
[switch]$Update,
[switch]$Usb,
[Switch]$UserProfileBackup,
[Switch]$ViewerRemote,
[Switch]$WinProfileRebuild
)
if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Warning "Get-PC requires powershell to be run as administrator. Please re-launch powershell as administrator."
break
}
<#$charA = $ComputerName.ToCharArray()
if($charA -contains '*'){
if($charA -lt 4){
Write-Host "Wildcard searches need to be at least 4 characters long" -ForegroundColor Red
return
}
Write-Host "Starting CMDB Wildcard Search..."
$searchResults = Search-CMDB -hostname $ComputerName.Replace('*','') | Sort-Object -Property Hostname
Write-Output $searchResults
if($TableView){
$searchResults | Out-GridView -Title 'Get-PC Wildcard Search'
}
return
}
#>
$getPCComputers = @() #List of computers that will get a batch query
$outPutArray = @() #For use near the end of the script to output to users screen in a specified format
$PCID = 1 #This is a helper variable for the progress bar
if ($Jobsprinters) {
#runs the printer query as a set of jobs
$outPutArray = Get-PCBatchJob($ComputerName) -printers
Write-Output $outPutArray
}
if (!$Jobsprinters) {
# Stuff only run once
if ($Update) {
#updates get pc
Update-GetPC
return
}
$NumberofComputers = $ComputerName.Count
foreach ($comp in $ComputerName) {
if ($PatchNotes) {
$scriptparent = (get-item $PSScriptRoot ).parent.FullName
Write-Host "`n"
Get-Content $scriptparent\patchnotes.txt
break
}
#Pulls user data from AD
if ($SHSUser) {
$user = Get-SHSUser $comp
$outPutArray += $user
continue
}
#Asset Tag Check
if ($comp.length -eq 5 -and !$SHSPrinter) {
$assettag = $comp
$comp = Get-AssetConversion $comp
if ($null -eq $comp) {
Write-Host "`n$assettag Asset Tag not in SMBIOS or CMDB" -ForegroundColor Red
$props = [Ordered]@{
Hostname = "$assettag Asset Tag not in SMBIOS"
Status = ""
'Current User' = ""
'Last User(s)' = ""
'IP | MAC' = ""
Model = ""
'OS' = ""
'OS Build' = ""
'BIOS Ver' = ""
Encryption = ""
'Free Space' = ""
RAM = ""
'SSO Client' = ""
'Kiosk Role' = ""
'Citrix Ver' = ""
'Asset Tag' = ""
'Service Tag' = ""
'Last Reboot' = ""
'TPM Status' = ""
'MBAM GPO' = ""
Printers = ""
}
$obj = New-Object -TypeName PSObject -Property $props
$outPutArray += $obj
continue
}
#Service Tag Check
}
elseif ($comp.length -eq 7) {
if (Resolve-DnsName $comp) {
#DREW SUCKS
}
else {
$serviceTag = $comp
$comp = Get-ServiceTagConversion $comp
if ($null -eq $comp) {
Write-Host "`n$serviceTag Service Tag not found in SCCM" -ForegroundColor Red
$props = [Ordered]@{
Hostname = "$serviceTag Service Tag not found in SCCM"
Status = ""
'Current User' = ""
'Last User(s)' = ""
'IP | MAC' = ""
Model = ""
'OS' = ""
'OS Build' = ""
'BIOS Ver' = ""
Encryption = ""
'Free Space' = ""
RAM = ""
'SSO Client' = ""
'Kiosk Role' = ""
'Citrix Ver' = ""
'Asset Tag' = ""
'Service Tag' = ""
'Last Reboot' = ""
'TPM Status' = ""
'MBAM GPO' = ""
Printers = ""
}
$obj = New-Object -TypeName PSObject -Property $props
$outPutArray += $obj
continue
}
}
}
#Pulls basic SNMP Data from printer $comp
if ($SHSPrinter) {
Write-Progress -Activity "Querying Printers" -Status "$comp ($PCID/$NumberofComputers)" -PercentComplete (($PCID / $NumberofComputers) * 100)
$printer = Get-SHSPrinter $comp
$outPutArray += $printer
$PCID++
continue
}
if ($SHSPrinterWeb) {
$printer = Get-SHSPrinter $comp
Write-Output $printer
Start-SHSPrinterWeb $printer
break
}
#Grabs all hostnames that have the requested printer installed on it
if ($HostnamesByPrinter) {
$printers = HostnamesByPrinter $comp
$out = @()
foreach ($printer in $printers) {
if ($printer -notlike '*EPIC*') {
$out += $printer
}
}
if ($TableView) {
$out | Out-GridView -Title "Workstations Associated with $comp"
}
else {
Write-Output $out
}
break
}
#Launches the request launcher script which containts landesk request template scripts
if ($RequestLauncher) {
Invoke-Expression \\int.samhealth.net\files\team\SHSISDesktopSolutions\Powershell\RequestLauncher\RequestLauncher.lnk
break
}
#Generates an available printer hostname. Useful for supplying a new hostname in new printer requests
if ($NextPrinterName) {
Find-NextPrinterName $comp
break
}
#PING HERE - All commands after here either require the computer to be online or need to know
#------------------------------------------------------------------------------------------------------------------------------------------------------------------#
$Connection = Test-Connection -ComputerName $comp -Count 1
Write-Progress -Activity "Connecting to computers" -Status "$comp ($PCID/$NumberofComputers)" -PercentComplete (($PCID / $NumberofComputers) * 100)
if ($Connection) {
$compStatus = 'Online'
}
else {
$compStatus = 'Offline'
}
#grabs some basic usb info from the wmi
if ($Usb) {
if ($compStatus -ne 'Online') {
Write-Warning "$comp is $compStatus unable to proccess command"
break
}
Get-USB $comp
break
}
#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 unable to proccess command"
continue
}
$out = Get-Devices $comp
if ($null -eq $out) {
Write-Warning "Unable to get device info for $comp"
continue
}
$outPutArray += $out
continue
}
#Pulls the event log for the past x days
if ($EventLog) {
if ($compStatus -ne 'Online') {
Write-Warning "$comp is $compStatus unable to proccess command"
break
}
Get-PCEventLog $comp
break
}
#Will remove selected users profile from C:\Users\ and cleans the registry of their profile
if ($WinProfileRebuild) {
if ($compStatus -ne 'Online') {
Write-Warning "$comp is $compStatus unable to proccess command"
break
}
Get-WinProfileRebuild $comp
break
}
if ($ResetRepository) {
if ($compStatus -ne 'Online') {
Write-Warning "$comp is $compStatus unable to proccess command"
break
}
Get-ResetRepository $comp
break
}
#Backs up user profile to specified destination
if ($UserProfileBackup) {
if ($compStatus -ne 'Online') {
Write-Warning "$comp is $compStatus unable to proccess command"
break
}
Get-UserProfileBackup $comp
break
}
#Remotely renames and restarts the computer.
if ($PCRename) {
if ($compStatus -ne 'Online') {
Write-Warning "$comp is $compStatus unable to proccess command"
break
}
Get-PCRename $comp
break
}
#removes temp, cache files, and inactive user profiles
if ($PCCleanup) {
if ($compStatus -ne 'Online') {
Write-Warning "$comp is $compStatus unable to proccess command"
break
}
Get-PCCleanup $comp
Get-PCProfileCleanup $comp
break
}
#Will reboot the users selected PC
if ($PCReboot) {
if ($compStatus -ne 'Online') {
Write-Warning "$comp is $compStatus unable to proccess command"
break
}
Get-PCReboot $comp
break
}
#Pulls brief overview of system resources
if ($Resources) {
if ($compStatus -ne 'Online') {
Write-Warning "$comp is $compStatus unable to proccess command"
continue
}
get-resources $comp
continue
}
#Pulls a list of installed programs from SCCM. May not be up to date if changes were made after the last sccm scan
if ($Apps) {
Get-Apps $comp $TableView
continue
}
if ($AppDiff) {
Get-AppDiff $comp $TableView
continue
}
if ($GPUpdate) {
if ($compStatus -ne 'Online') {
Write-Warning "$comp is $compStatus unable to proccess command"
break
}
Get-GPUpdate $comp
break
}
#Will not notify the user that another user is about to remote onto their PC
if ($Bypass) {
if ($compStatus -ne 'Online') {
Write-Warning "$comp is $compStatus unable to proccess command"
break
}
Get-Bypass $comp
}
#Runs Remote Viewer, Thick Client Only
if ($ViewerRemote) {
if ($compStatus -ne 'Online') {
Write-Warning "$comp is $compStatus unable to proccess command"
break
}
Get-ViewerRemote $comp
continue
}
#Runs Remote Desktop Connection Application
if ($RemoteDesktopApp) {
if ($compStatus -ne 'Online') {
Write-Warning "$comp is $compStatus unable to proccess command"
break
}
Get-RemoteDesktopApp $comp
break
}
#Same as C$ into a workstation
if ($FileSystem) {
if ($compStatus -ne 'Online') {
Write-Warning "$comp is $compStatus unable to proccess command"
continue
}
Get-FileSystem $comp
continue
}
#Will log off the current logged in user for the designated PC
#Adapted from Josh Gobens Logoff Script
if ($LogOffUser) {
if ($compStatus -ne 'Online') {
Write-Warning "$comp is $compStatus unable to proccess command"
break
}
Get-LogOffUser $comp
break
}
if ($InstallNet35) {
Get-InstallNet35 $comp
continue
}
#Checks if there is a WinRM service error
#TODO Re-evaluate where we want the WSNetwork test
#$WSNetworkTest = Test-WSMan -ComputerName $comp
#-or ($null -eq $WSNetworkTest)
#checks to see if the computer is in AD or the disabled computers OU and warns the user
if (get-module -ListAvailable -Name 'ActiveDirectory') {
Write-Progress -Activity "Looking up computer in AD" -Status "$comp ($PCID/$NumberofComputers)" -PercentComplete (($PCID / $NumberofComputers) * 100)
try { $adTest = ((Get-ADComputer $comp).DistinguishedName -match "Disabled Computers") } catch { $adTest = $true }
if ($adTest) {
Write-Warning "$comp is either disabled or off the domain"
}
}
#Direct SCCM Queries
if ( $SCCM ) {
$result = Get-SCCMQuery $comp $NumberofComputers $PCID
$PCID++
$outPutArray += $result
}
else {
#Checks if local computer
if ($comp -eq $env:COMPUTERNAME) {
$result = Get-PCLocal $comp $NumberofComputers $PCID
#$PCID++
#$result = get-PCremoteCleaned $comp $Connection $NumberofComputers $PCID
$outPutArray += $result
#$getPCComputers += $comp
}
else {
#$result = Get-PCRemote $comp $NumberofComputers $PCID
#$result = get-PCremoteCleaned $comp $Connection $NumberofComputers $PCID
#$PCID++
#$outPutArray += $result
#Write-Output $result
$getPCComputers += $comp
}
}
if ($Orion) {
break
}
}
}
#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 ($Orion) {
$mac = $outPutArray[0].'IP | MAC' -split " "
if ($mac) {
$mac = $mac[2] -split ","
$mac = $mac[0]
Write-Host "Launching Orion page to $mac"
Start-Process "https://shsorion/Orion/UDT/EndpointDetails.aspx?NetObject=UE-MAC:VAL=$mac"
}
else {
Write-Host "Unable to validate MAC"
}
}
Write-Output $outPutArray
#Creats an out grid view of all the data collected
if ($TableView) {
$outPutArray | Out-GridView -Title "Get-PC Grid"
}
#Takes the outputed data and exports it to a csv in the user's temp folder. Then opens that file with default csv viewer. It should be excel for most users
if ($Excel) {
ExportToExcel $outPutArray
}
}
Function ProgressBar($Percent, $CurrentPC, $CurrentLocationText, $NumberofComputers, $CurrentPCNumber) {
Write-Progress -Activity "Scanning PC $CurrentPC ($CurrentPCNumber/$NumberofComputers)" -Status "Querying: $CurrentLocationText" -PercentComplete (($Percent / 18) * 100)
}

177
README.md Normal file
View file

@ -0,0 +1,177 @@
# Get-PC
Get-PC is a custom Powershell module that contains many useful features for querying details about workstations and also performing many useful/common functions on those computers remotely.
## Installing
Get-PC is available through Software Center. Simply locate it there and choose install.
## Usage
**Get System Information**
```Powershell
PS C:\> get-pc hostname
```
Using *get-pc hostname* will query a workstation (or multiple workstations, comma separated) for information such as model, SSO client, currently logged in user, OS version, RAM, installed printers, etc…
**Access the Workstations File System**
```PowerShell
PS C:\> get-pc GSHZZ12345 -FileSystem
```
Using the -f (or -FileSystem) flag opens Windows File Explorer to the \\hostname\C$ path for you.
**Get a List of Installed Applications**
```PowerShell
PS C:\> get-pc GSHZZ12345 -Apps
```
Using the -a (or -Apps) flag will return a list of installed applications on the workstation.
**Remote onto a Workstation**
```PowerShell
PS C:\> get-pc GSHZZ12345 -ViewerRemote
```
Using the -V (or -ViewerRemote) flag will launch the SCCM ConfigMgr Remote Viewer and connect it to the supplied hostname.
 
Note: This requires that the SCCM Thick Client be installed on the workstation you are running Get-PC on. It can be installed via Software Center.
```PowerShell
PS C:\> get-pc GSHZZ12345 -RemoteDesktopApp
```
Using -RemoteDesktopApp flag will launch RDP into the supplied hostname
**Logoff Remote User**
```PowerShell
PS C:\> get-pc GSHZZ12345 -LogOffUser
```
Using the -L (or -LogOffUser) flag will attempt to log the currently signed on user off the workstation.
**Copy User Profiles**
```PowerShell
PS C:\> get-pc GSHZZ12345 -UserProfileBackup
```
Using -UserProfileBackup flag will allow you to copy a user profile to the Desktop Solutions shared drive. This automatically copies over the Desktop, Documents, Downloads, Favorites, Pictures, Videos, Chrome Bookmarks, and AppData/Roaming/Microsoft folder to a network location based on the chosen site
Any username can be entered that exists on the workstation, but the three most recent are displayed for convenience.
**Restore User Profiles**
```PowerShell
PS C:\> get-pc GSHZZ12345 -UserProfileBackup
```
Using -UserProfileBackup flag will allow you to also restore a user profile from the Desktop Solutions shared drive. Simply select R when prompted, then using the number next to the available back-up, select the one you want to restore. This will automatically copy over the Desktop, Documents, Downloads, Favorites, Pictures, Videos, and AppData/Roaming/Microsoft folder back to the users profile on the machine. (Their profile must exist on the machine or the copy will fail, so the user will have to login first before you can restore their files over successfully.)
Any username can be entered that exists on the workstation, but the three most recent are displayed for convenience.
**Bypass Security Prompt When Remoting On**
```PowerShell 
PS C:\> get-pc GSHZZ12345 -B
```
Using the -b (or -Bypass) flag will bypass the prompt the remote user sees to approve a user remoting onto the workstation. This is particularly useful for remoting onto Kiosked workstations.
 
TIP: -B can be used in addition to -V to bypass and remote on in one command:
```PowerShell
PS C:\> get-pc GSHZZ12345 -b -v
```
**Rebuild Users Windows Profile**
```PowerShell 
PS C:\> get-pc GSHZZ12345 -WinProfileRebuild
```
Using the -WinProfileRebuild flag will rename the users Windows profile folder with a timestamp and remove the appropriate registry key. Once the user signs back in, the files can be copied over to their new Windows profile from the .backup folder that was created. This command can also be use to automatically restore the files using the R option when prompted.
**Rename a PC**
```PowerShell
PS C:\> get-pc GSHZZ12345 -PCRename
```
Using the -PCRename flag will allow you to remotely rename a workstation. You will be prompted to enter your credentials. Upon successfully renaming the PC, it will then force a restart of the workstation so the new hostname takes effect.
**Update Group Policy**
```PowerShell
PS C:\> get-pc GSHZZ12345 -GPUpdate
```
Using the -GPUpdate flag will attempt to update the group policy on the workstation.
**Get Historical/SCCM Data**
```PowerShell
PS C:\> get-pc GSHZZ12345 -sccm
```
Using the -SCCM flag will query SCCM directly. Get-PC falls back to SCCM when a workstation is offline automatically, but this is useful when you dont necessarily need the current information about the machine particularly when querying multiple computers since querying SCCM is faster than reaching out to each machine for live data.
(For example, you know SCCM has the correct model information all the time, so even though its “historical” the model of a computer doesnt change.)
**Get a Table/Gridview of Get-PC Output**
```PowerShell
PS C:\> get-pc GSHZZ12345 -Tableview
```
Using the -T (or -Tableview) flag will have Get-PC open up a nice GUI window with all of the data it was able to query. This is useful for sorting large lists of workstations or copying into an Excel file to work with. You can also use -t in addition to -a to get a table view of installed applications on a machine.
Examples:
*get-pc GSHZZ12345 -t -a* will output the computers applications in the GUI table
**Get SHS User Info**
```PowerShell
PS C:\> get-pc GSHZZ12345 -shsuser
```
Using the -shsuser flag will have Get-PC return user information pulled from Active Directory. Either username or employeeID can be used for the query.
Examples:
```PowerShell
PS C:\> get-pc scarlton -SHSUser
PS C:\> get-pc 40504 -shsuser
```
**Get SHS Printer Data**
```PowerShell
PS C:\> get-pc PGSHZZ01 -shsprinter
```
Using the -shsprinter flag will pull SMTP data from the printer. It will fall back on cmdb data if the printer is offline.
```PowerShell
PS C:\> get-pc PGSHZZ01 -shsprinterweb
```
Using the -shsprinterweb flag will pull the same info as -shsprinter but will also launch the default web browser to the web interface and orion
**Get Connected Device Info**
```PowerShell
PS C:\> get-pc GSHZZ12345 -devices
```
Using the -devices flag will pull the currently connected USB devices and monitors. There is currently a look up table for common SHS supplied peripherals to help match on items supplied by IS.
**Get the Event Log**
```Powershell
PS C:\> get-pc GSHZZ12345 -EventLog
```
Using the -EventLog flag will pull the errors from event log for the given hostname. It will ask you how many days back you would like to see then launch in an out-gridview.
**Accessing CMDB**
```Powershell
PS C:\> get-pc GSHZZ12345 -cmdb
```
Using the -cmdb flag will launch the default web browser the cmdb page for the given hostname.
```Powershell
PS C:\> get-pc GSHZZ12345 -cmdblocation
```
Using the -cmdblocation flag will allow you to easily update the cmdb location of the given hostname.
**Launching Orion**
```Powershell
PS C:\> get-pc GSHZZ12345 -orion
```
Using the -orion flag will query the given hostname for its MAC address then launch the default web browser to the orion page for that MAC address.
**Updating Get-PC**
```PowerShell
PS C:\> get-pc -update
```
When there is an updated version of get-pc available the user will be notified on the first time using get-pc in that powershell window.
Using the -update flag will automatically download the most up-to-date version of get-pc to the user's machine.
## Authors
Chuck Beddow
Drew York

200
patchnotes.txt Normal file
View file

@ -0,0 +1,200 @@
Patch: 2024-06-10
-Updated Apps to do a local query, picking up apps that SCCM missed
Patch: 2024-06-05
-Add network interface to main output
-Add free RAM to main output
-Factored out UserProfileTransfer in anticipation of custom paths
Patch: 2023-01-17
-Fix format on WinProfileRebuild.ps1
-Fix format on Get-PC.ps1
-Fix format on Apps.ps1
-No version change
Patch: 2023-01-16
-Add new module -InstallNet35
Patch: 2023-01-13
-Remove calls to CBDM in main function
-Remove -cmdb, -cmdblocation and -location
-Clean formating of code in Get-PC, AssetConversion, SCCMQuery and PCRemote
-Add CONST's to SCCMQuery to cut down on clutter
-Rename all get-pc switches to start with capital
Patch: 2022-10-27
-Reverted PCRename change
Patch: 2022-10-27
-fixed issue with pcrename
Patch: 2022-08-03
-Fixed a bug with the SSO client status due to an Imprivata change
Patch: 2021-08-04
-updated shsprinter to use the location calc string
-updated windows version display to use the new regkey
-Added mobile devices to cmdb fallback
Patch: 2021-03-12
-updated lookup table for 5080 chassis
-Changed how the script determines the last login time of a user. This should fix the issue with all users appearing to have logged in recently.
-updated query to get _SHSCalcLocationString
-Changed the landesk query to grab _SHSCalcLocationString Get-CMDBLocation now user the longer of the two _SHSCalcLocationString and _SHSLocation3
Patch: 2020-11-10
-Userprofilebackup now excludes Teams cache
Patch: 2020-09-25
-Added wildcard cmdb searches and cmdb location searches
-fixed shsprinter progress bar
-fixed bug related to querying the file system for multiple computers
-Added some progress bars to common actions
-Removed unneed pauses from PCReboot and LogOffUser
-Added error checking to SCCM queries for dupes in sccm. Added more detailed output for PCCleanup GPUpdate will now automatically remove the old group policy before updating it.
Patch: 2020-07-07
-bug fix with cmdb loc
-fixed spelling bug in help
Patch: 2020-06-24
-fixed a bug with -devices
Patch: 2020-06-19
-updated devices for 17in monitors
-made changes to cmdb location to reflect changes in landesk
-Added custom formatting to overwrite defaults for -apps and -devices
Patch: 2020-05-28
-Added Anesthesia carts to chassis type
-Added DEL list lookup and support
-Added CMDB Fallback for queries with no SCCM data
-Added -devices to query all monitors and usb devices attached to the computer
-made -cmdb have an assettag fallback
-assorted minor bug fixes
Patch: 2020-04-14
-Added CMDB data to shsprinter
-Added some error checking for WinProfileRebuild folder rename
-Updated SHSUser to accept full names
Patch: 2020-03-25
-fixed bug in TPM Status
Patch: 2020-03-20
-Added a warning for invalid inputs in -userprofilebackup
-fixed bug causing shsuser not to work with -excel
Patch: 2020-03-04
-updated wording in PCCleanup to be more clear
Patch: 2020-03-03
-updated path for -update and version check
Patch: 2020-03-02
-added cm01 path for updates and version check
-fixed issue with the coast's totes adorbs baby hostname
-added output for successful branch cache clearing
Patch: 2020-02-26
-added -orion to launch into orion page for workstations
Patch: 2020-02-21
-updated help
-added ClearBCCache to pccleanup
-added multi computer support to -apps
-added -update for new installation method
Patch: 2020-02-17
-Added a timeout for online hosts with broken cmi
-Added a restore built into WinProfileRebuild
-Updated path for request launcher
Patch: 2020-02-06
-removed the #require to run as adminstrator and instead made it show an error and exit
Patch: 2020-02-04
-fixed a bug pulling cp3525 -shsprinter
-added install date to -apps
-made batchinvoke default for multiple queries
-fixed bug when querying win7 computers with old powershell and broken wmi
Patch: 2020-01-31
-Added the ability to get-pc multiple computers much faster by using Invoke-command asynchronously
Patch: 2020-01-30
-added -cmdblocation to update the location field in cmdb
Patch: 2020-01-29
-Added test to see if computer is disabled or off the domain
-added progress bar to jobs
-removed kiosk and decom request
-added -excel to create csv in temp and launch it with excel
Patch: 2020-01-28
-Added running get-pc as seperate jobs
-bug fix when pulling imprivata type
-bug fix in shsprinter for officejets
-Cleaned up get-pc, reducing calls by 30%
-fixed bug causing no chassis type when querying sccm
Patch: 2020-01-23
-Added fuser level to shsprinter
-Added snmp calls to shsprinter to grab toner info
Patch: 2020-01-21
-fixed bug when pulling MACs from 4250 and 4015s
-Added status for shsprinters including zebras
Patch: 2020-01-17
-added info to shsprinter
-Added orion web popup in shsprinterweb
Patch: 2020-01-13
-fixed bug causing -apps not to work for offline comps
-fixed a bug in profile restore for certain sites
-added -usb to pull basic usb device data
-Added total page count to shsprinter
Patch: 2020-01-09
-UserProfileBackup now copies files to the new locations on SCCM servers
-Added SHSPrinterWeb to launch the web interface for a printer
-fixed a bug in winprofilerebuild
Patch: 2020-01-07
-Added -cmdb to launch the landesk cmdb page in IE
-changed winprofile rebuild to allow rebuilding while users are logged in
Patch: 2020-01-03
-fixed bug when rebuilding winprofile on local machine
-added ability to see patchnotes with -patchnotes
-can now comma seperate for shsuser
-Bug fix on local pc drive size
-Added Precision to list of models
-Changed current user name to show (RDP/Inactive) since locked profiles are showing as RDP
-added total drive size to freespace output
-Changes to -HostnameByPrinter to allow pipe support
-Added a cmdb location data check Will warn if cmdb mismatch or empty location data
-Added CMDB location query
-fixed bug in get username to stop profile generation when script is run.
-Added -RequestLauncher which runs the request launcher script
-fixed bug in logoff user if no user is logged on
-Added error checking to stop rebuilding own profile
-now returns an online user for RDP sessions
-rewritten much of the code for get-pc. It is now in a form that matches most of the current shs powershell modules on gitlab. Get-pc now also properly interacts with the pipeline.