Refactored main, currently broke job system but there is a plan to rework the job system
This commit is contained in:
parent
61038d43e5
commit
e17f7e6ba3
|
|
@ -78,6 +78,9 @@ function Get-Devices {
|
||||||
$item.PSObject.TypeNames.Insert(0,'GetPC.Devices')
|
$item.PSObject.TypeNames.Insert(0,'GetPC.Devices')
|
||||||
$out += $item
|
$out += $item
|
||||||
}
|
}
|
||||||
|
$item = [PSCustomObject]@{ }
|
||||||
|
$item.PSObject.TypeNames.Insert(0,'GetPC.Devices')
|
||||||
|
$out += $item
|
||||||
|
|
||||||
Write-Output $out
|
Write-Output $out
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,30 @@
|
||||||
function Get-Hostname ([string]$name) {
|
function Get-Hostname ([string]$name) {
|
||||||
|
$errMsg = ''
|
||||||
if ($name.Length -eq 5) {
|
if ($name.Length -eq 5) {
|
||||||
$res = Get-AssetConversion $name
|
$res = Get-AssetConversion $name
|
||||||
if ($res) { return $res }
|
if ($res) { return $res,'' }
|
||||||
|
else { $errMsg += "$name Asset Tag not in SMBIOS or CMDB. "}
|
||||||
}
|
}
|
||||||
# Regex to match IP Address brought to you by https://stackoverflow.com/a/36760050
|
# Regex to match IP Address brought to you by https://stackoverflow.com/a/36760050
|
||||||
if ($name -match "^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$") {
|
if ($name -match "^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$") {
|
||||||
$res = Resolve-DnsName $name
|
$res = Resolve-DnsName $name
|
||||||
if ($res -and $res.NameHost -and ($res.NameHost -match "([^.]*)\.int\.samhealth\.net")) {
|
if ($res -and $res.NameHost -and ($res.NameHost -match "([^.]*)\.int\.samhealth\.net")) {
|
||||||
return $Matches[1]
|
return $Matches[1],''
|
||||||
|
} else {
|
||||||
|
$errMsg += "$name IP Address couldn't be resolved to hostname"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($name.Length -eq 7) {
|
if ($name.Length -eq 7) {
|
||||||
$res = Get-ServiceTagConversion $name
|
$res = Get-ServiceTagConversion $name
|
||||||
if ($res) { return $res }
|
if ($res) { return $res,'' }
|
||||||
|
else { $errMsg += "$name Service Tag not found in SCCM"}
|
||||||
}
|
}
|
||||||
# Regex to match MAC Address brought to you by https://stackoverflow.com/a/4260512
|
# Regex to match MAC Address brought to you by https://stackoverflow.com/a/4260512
|
||||||
if ($name -match "^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$") {
|
if ($name -match "^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$") {
|
||||||
$res = Get-SCCM_PCFromMAC $name
|
$res = Get-SCCM_PCFromMAC $name
|
||||||
if ($res) { return $res }
|
if ($res) { return $res,'' }
|
||||||
|
else { $errMsg += "$name MAC Address not found in SCCM"}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $name
|
return $name, $errMsg
|
||||||
}
|
}
|
||||||
|
|
@ -8,8 +8,12 @@
|
||||||
Write-Host "Current Hostname: $ComputerName"
|
Write-Host "Current Hostname: $ComputerName"
|
||||||
$NewHostName = Read-Host "New Hostname"
|
$NewHostName = Read-Host "New Hostname"
|
||||||
|
|
||||||
Rename-Computer -ComputerName $ComputerName -NewName $NewHostName -DomainCredential $DomainUser -force -Restart
|
$res = Rename-Computer -ComputerName $ComputerName -NewName $NewHostName -DomainCredential $DomainUser -force -Restart -PassThru
|
||||||
Write-Host "Renamed PC, successful. Restarting PC... Old Hostname: $ComputerName, New Hostname: $NewHostName" -ForegroundColor Green
|
if ($res.HasSucceeded) {
|
||||||
|
Write-Host "Renamed PC, successful. Restarting PC... Old Hostname: $ComputerName, New Hostname: $NewHostName" -ForegroundColor Green
|
||||||
|
} else {
|
||||||
|
Write-Host "Failed to rename PC. Check user credentials" -ForegroundColor Red
|
||||||
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@
|
||||||
} elseif ($site -eq $numSites) {
|
} elseif ($site -eq $numSites) {
|
||||||
$BackupDestination = Read-Host "Enter a PC asset, hostname, or custom path"
|
$BackupDestination = Read-Host "Enter a PC asset, hostname, or custom path"
|
||||||
# Will attempt to convert to Hostname if possible, doesn't change if not
|
# Will attempt to convert to Hostname if possible, doesn't change if not
|
||||||
$BackupDestination = Get-Hostname $BackupDestination
|
$BackupDestination,$null = Get-Hostname $BackupDestination
|
||||||
# Treat as hostname and see if it's reachable
|
# Treat as hostname and see if it's reachable
|
||||||
if (Test-Connection -ComputerName $BackupDestination -Count 1) {
|
if (Test-Connection -ComputerName $BackupDestination -Count 1) {
|
||||||
# If so, get the filesystem path
|
# If so, get the filesystem path
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#region Module Import Block
|
#region Module Import Block
|
||||||
|
|
||||||
$ErrorActionPreference = 'SilentlyContinue'
|
#$ErrorActionPreference = 'SilentlyContinue'
|
||||||
#DevStage can take either Dev or Prod as values
|
#DevStage can take either Dev or Prod as values
|
||||||
$devStage = 'Dev'
|
$devStage = 'Dev'
|
||||||
#Locations for dev build and prod build
|
#Locations for dev build and prod build
|
||||||
|
|
@ -53,7 +53,6 @@ Function Get-PC {
|
||||||
-PCReboot | reboots computer
|
-PCReboot | reboots computer
|
||||||
-PCRename | renames computer
|
-PCRename | renames computer
|
||||||
-RemoteDesktopApp | remote into computer using RDP
|
-RemoteDesktopApp | remote into computer using RDP
|
||||||
-RequestLauncher | starts request launcher
|
|
||||||
-ResetRepository | remotely resets repository
|
-ResetRepository | remotely resets repository
|
||||||
-Resources | more details about system resources
|
-Resources | more details about system resources
|
||||||
-PrinterPurge | removes printer from all online computers
|
-PrinterPurge | removes printer from all online computers
|
||||||
|
|
@ -104,7 +103,6 @@ Function Get-PC {
|
||||||
[Switch]$PCRename,
|
[Switch]$PCRename,
|
||||||
[Switch]$Quiet,
|
[Switch]$Quiet,
|
||||||
[Switch]$RemoteDesktopApp,
|
[Switch]$RemoteDesktopApp,
|
||||||
[Switch]$RequestLauncher,
|
|
||||||
[Switch]$Resources,
|
[Switch]$Resources,
|
||||||
[Switch]$ResetRepository,
|
[Switch]$ResetRepository,
|
||||||
[Switch]$PrinterPurge,
|
[Switch]$PrinterPurge,
|
||||||
|
|
@ -127,445 +125,405 @@ Function Get-PC {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
<#$charA = $ComputerName.ToCharArray()
|
# Stuff only run once
|
||||||
if($charA -contains '*'){
|
if ($Update) {
|
||||||
if($charA -lt 4){
|
#updates get pc
|
||||||
Write-Host "Wildcard searches need to be at least 4 characters long" -ForegroundColor Red
|
Update-GetPC
|
||||||
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
|
return
|
||||||
}
|
}
|
||||||
#>
|
|
||||||
|
if ($PatchNotes) {
|
||||||
|
$scriptparent = (get-item $PSScriptRoot ).parent.FullName
|
||||||
|
Write-Host "`n"
|
||||||
|
Get-Content $scriptparent\patchnotes.txt
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$getPCComputers = @() #List of computers that will get a batch query
|
$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
|
$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
|
$PCID = 1 #This is a helper variable for the progress bar
|
||||||
|
|
||||||
if ($Jobsprinters) {
|
$NumberofComputers = $ComputerName.Count
|
||||||
#runs the printer query as a set of jobs
|
foreach ($comp in $ComputerName) {
|
||||||
$outPutArray = Get-PCBatchJob($ComputerName) -printers
|
#Pulls user data from AD
|
||||||
Write-Output $outPutArray
|
if ($SHSUser) {
|
||||||
|
$user = Get-SHSUser $comp
|
||||||
}
|
$outPutArray += $user
|
||||||
|
continue
|
||||||
if (!$Jobsprinters) {
|
|
||||||
# Stuff only run once
|
|
||||||
if ($Update) {
|
|
||||||
#updates get pc
|
|
||||||
Update-GetPC
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$NumberofComputers = $ComputerName.Count
|
$oldcomp = $comp
|
||||||
foreach ($comp in $ComputerName) {
|
$comp,$msg = Get-Hostname $comp
|
||||||
|
if ($msg) {
|
||||||
|
Write-Host "`n$msg" -ForegroundColor Red
|
||||||
|
|
||||||
if ($PatchNotes) {
|
$props = [Ordered]@{
|
||||||
$scriptparent = (get-item $PSScriptRoot ).parent.FullName
|
Hostname = "$msg"
|
||||||
Write-Host "`n"
|
Status = ""
|
||||||
Get-Content $scriptparent\patchnotes.txt
|
'Current User' = ""
|
||||||
break
|
'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
|
||||||
|
|
||||||
#Pulls user data from AD
|
$outPutArray += $obj
|
||||||
if ($SHSUser) {
|
|
||||||
$user = Get-SHSUser $comp
|
|
||||||
$outPutArray += $user
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
$oldcomp = $comp
|
continue
|
||||||
$comp = Get-Hostname $comp
|
}
|
||||||
if (($oldcomp -eq $comp) -and (($comp.length -eq 5 -and !$SHSPrinter) -or ($comp.length -eq 7))) {
|
|
||||||
if ($comp.length -eq 5 -and !$SHSPrinter) {
|
#DREW SUCKS
|
||||||
$msg = "$comp Asset Tag not in SMBIOS or CMDB"
|
|
||||||
Write-Host "`n$msg" -ForegroundColor Red
|
#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
|
||||||
}
|
}
|
||||||
elseif ($comp.length -eq 7) {
|
|
||||||
$msg = "$comp Service Tag not found in SCCM"
|
|
||||||
Write-Host "`n$msg" -ForegroundColor Red
|
|
||||||
}
|
|
||||||
|
|
||||||
$props = [Ordered]@{
|
|
||||||
Hostname = "$msg"
|
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#DREW SUCKS
|
if ($TableView) {
|
||||||
|
$out | Out-GridView -Title "Workstations Associated with $comp"
|
||||||
#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
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($PrinterPurge) {
|
|
||||||
Invoke-PrinterPurge $comp
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
#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
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($Wake) {
|
|
||||||
Invoke-Wake $comp
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
#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 {
|
else {
|
||||||
$compStatus = 'Offline'
|
Write-Output $out
|
||||||
}
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
#grabs some basic usb info from the wmi
|
if ($PrinterPurge) {
|
||||||
if ($Usb) {
|
Invoke-PrinterPurge $comp
|
||||||
if ($compStatus -ne 'Online') {
|
continue
|
||||||
Write-Warning "$comp is $compStatus unable to proccess command"
|
}
|
||||||
break
|
|
||||||
}
|
#Generates an available printer hostname. Useful for supplying a new hostname in new printer requests
|
||||||
Get-USB $comp
|
if ($NextPrinterName) {
|
||||||
|
Find-NextPrinterName $comp
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($Wake) {
|
||||||
|
Invoke-Wake $comp
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
#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
|
break
|
||||||
}
|
}
|
||||||
|
Get-USB $comp
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
#grabs info on attached monitors and usb devices
|
#grabs info on attached monitors and usb devices
|
||||||
if ($Devices) {
|
if ($Devices) {
|
||||||
ProgressBar -CurrentPC $comp -NumberofComputers $NumberofComputers -Percent $PCID -CurrentLocationText 'Devices' -CurrentPCNumber $PCID
|
ProgressBar -CurrentPC $comp -NumberofComputers $NumberofComputers -Percent $PCID -CurrentLocationText 'Devices' -CurrentPCNumber $PCID
|
||||||
$PCID++
|
$PCID++
|
||||||
|
|
||||||
if ($compStatus -ne 'Online') {
|
if ($compStatus -ne 'Online') {
|
||||||
Write-Warning "$comp is $compStatus skipping monitor query"
|
Write-Warning "$comp is $compStatus skipping monitor query"
|
||||||
}
|
}
|
||||||
|
|
||||||
$out = Get-Devices $comp $compStatus
|
$out = Get-Devices $comp $compStatus
|
||||||
if ($null -eq $out) {
|
if ($null -eq $out) {
|
||||||
Write-Warning "Unable to get device info for $comp"
|
Write-Warning "Unable to get device info for $comp"
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
$outPutArray += $out
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
#Pulls the event log for the past x days
|
$outPutArray += $out
|
||||||
if ($EventLog) {
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if ($compStatus -ne 'Online') {
|
#Pulls the event log for the past x days
|
||||||
Write-Warning "$comp is $compStatus unable to proccess command"
|
if ($EventLog) {
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
Get-PCEventLog $comp
|
if ($compStatus -ne 'Online') {
|
||||||
|
Write-Warning "$comp is $compStatus unable to proccess command"
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
#Will remove selected users profile from C:\Users\ and cleans the registry of their profile
|
Get-PCEventLog $comp
|
||||||
if ($WinProfileRebuild) {
|
break
|
||||||
|
}
|
||||||
|
|
||||||
if ($compStatus -ne 'Online') {
|
#Will remove selected users profile from C:\Users\ and cleans the registry of their profile
|
||||||
Write-Warning "$comp is $compStatus unable to proccess command"
|
if ($WinProfileRebuild) {
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
Get-WinProfileRebuild $comp
|
if ($compStatus -ne 'Online') {
|
||||||
|
Write-Warning "$comp is $compStatus unable to proccess command"
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($ResetRepository) {
|
Get-WinProfileRebuild $comp
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
if ($compStatus -ne 'Online') {
|
if ($ResetRepository) {
|
||||||
Write-Warning "$comp is $compStatus unable to proccess command"
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
Get-ResetRepository $comp
|
if ($compStatus -ne 'Online') {
|
||||||
break
|
Write-Warning "$comp is $compStatus unable to proccess command"
|
||||||
}
|
|
||||||
|
|
||||||
#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
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
#Pulls a list of installed programs from SCCM. May not be up to date if changes were made after the last sccm scan
|
Get-ResetRepository $comp
|
||||||
if ($Apps) {
|
continue
|
||||||
Get-Apps $comp $TableView
|
}
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($AppDiff) {
|
#Backs up user profile to specified destination
|
||||||
Get-AppDiff $comp $TableView
|
if ($UserProfileBackup) {
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($UninstallProgram) {
|
if ($compStatus -ne 'Online') {
|
||||||
Invoke-UninstallProgram $comp
|
Write-Warning "$comp is $compStatus unable to proccess command"
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($GPUpdate) {
|
Get-UserProfileBackup $comp
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
if ($compStatus -ne 'Online') {
|
#Remotely renames and restarts the computer.
|
||||||
Write-Warning "$comp is $compStatus unable to proccess command"
|
if ($PCRename) {
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
Get-GPUpdate $comp
|
if ($compStatus -ne 'Online') {
|
||||||
|
Write-Warning "$comp is $compStatus unable to proccess command"
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
#Will not notify the user that another user is about to remote onto their PC
|
Get-PCRename $comp
|
||||||
if ($Bypass) {
|
break
|
||||||
|
}
|
||||||
|
|
||||||
if ($compStatus -ne 'Online') {
|
#removes temp, cache files, and inactive user profiles
|
||||||
Write-Warning "$comp is $compStatus unable to proccess command"
|
if ($PCCleanup) {
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
Get-Bypass $comp
|
if ($compStatus -ne 'Online') {
|
||||||
}
|
Write-Warning "$comp is $compStatus unable to proccess command"
|
||||||
|
|
||||||
#Removes any indicator that another user is remoted onto their PC (like the green bar)
|
|
||||||
if ($Quiet) {
|
|
||||||
|
|
||||||
if ($compStatus -ne 'Online') {
|
|
||||||
Write-Warning "$comp is $compStatus unable to proccess command"
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
Invoke-Quiet $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
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
#Same as C$ into a workstation
|
Get-PCCleanup $comp
|
||||||
if ($FileSystem) {
|
Get-PCProfileCleanup $comp
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
if ($compStatus -ne 'Online') {
|
#Will reboot the users selected PC
|
||||||
Write-Warning "$comp is $compStatus unable to proccess command"
|
if ($PCReboot) {
|
||||||
continue
|
if ($compStatus -ne 'Online') {
|
||||||
}
|
Write-Warning "$comp is $compStatus unable to proccess command"
|
||||||
|
|
||||||
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
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($InstallNet35) {
|
Get-PCReboot $comp
|
||||||
Get-InstallNet35 $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 and Get-Package
|
||||||
|
if ($Apps) {
|
||||||
|
Get-Apps $comp $TableView
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($AppDiff) {
|
||||||
|
Get-AppDiff $comp $TableView
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($UninstallProgram) {
|
||||||
|
Invoke-UninstallProgram $comp
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
#Removes any indicator that another user is remoted onto their PC (like the green bar)
|
||||||
|
if ($Quiet) {
|
||||||
|
|
||||||
|
if ($compStatus -ne 'Online') {
|
||||||
|
Write-Warning "$comp is $compStatus unable to proccess command"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
Invoke-Quiet $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
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
#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
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
#Checks if there is a WinRM service error
|
Get-FileSystem $comp
|
||||||
#TODO Re-evaluate where we want the WSNetwork test
|
continue
|
||||||
#$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
|
#Will log off the current logged in user for the designated PC
|
||||||
if (get-module -ListAvailable -Name 'ActiveDirectory') {
|
#Adapted from Josh Gobens Logoff Script
|
||||||
Write-Progress -Activity "Looking up computer in AD" -Status "$comp ($PCID/$NumberofComputers)" -PercentComplete (($PCID / $NumberofComputers) * 100)
|
if ($LogOffUser) {
|
||||||
try { $adTest = ((Get-ADComputer $comp).DistinguishedName -match "Disabled Computers") } catch { $adTest = $true }
|
|
||||||
|
|
||||||
if ($adTest) {
|
if ($compStatus -ne 'Online') {
|
||||||
Write-Warning "$comp is either disabled or off the domain"
|
Write-Warning "$comp is $compStatus unable to proccess command"
|
||||||
}
|
break
|
||||||
Write-Progress -Activity "Looking up computer in AD" -Completed
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#Direct SCCM Queries
|
Get-LogOffUser $comp
|
||||||
if ( $SCCM ) {
|
break
|
||||||
$result = Get-SCCMQuery $comp $NumberofComputers $PCID
|
}
|
||||||
$PCID++
|
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
Write-Progress -Activity "Looking up computer in AD" -Completed
|
||||||
|
}
|
||||||
|
|
||||||
|
#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
|
$outPutArray += $result
|
||||||
|
#$getPCComputers += $comp
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
#$result = Get-PCRemote $comp $NumberofComputers $PCID
|
||||||
|
#$result = get-PCremoteCleaned $comp $Connection $NumberofComputers $PCID
|
||||||
|
#$PCID++
|
||||||
|
#$outPutArray += $result
|
||||||
|
#Write-Output $result
|
||||||
|
$getPCComputers += $comp
|
||||||
|
|
||||||
#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
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($Orion) {
|
||||||
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue