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')
|
||||
$out += $item
|
||||
}
|
||||
$item = [PSCustomObject]@{ }
|
||||
$item.PSObject.TypeNames.Insert(0,'GetPC.Devices')
|
||||
$out += $item
|
||||
|
||||
Write-Output $out
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +1,30 @@
|
|||
function Get-Hostname ([string]$name) {
|
||||
$errMsg = ''
|
||||
if ($name.Length -eq 5) {
|
||||
$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
|
||||
if ($name -match "^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$") {
|
||||
$res = Resolve-DnsName $name
|
||||
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) {
|
||||
$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
|
||||
if ($name -match "^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$") {
|
||||
$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"
|
||||
$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
|
||||
$res = Rename-Computer -ComputerName $ComputerName -NewName $NewHostName -DomainCredential $DomainUser -force -Restart -PassThru
|
||||
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{
|
||||
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@
|
|||
} elseif ($site -eq $numSites) {
|
||||
$BackupDestination = Read-Host "Enter a PC asset, hostname, or custom path"
|
||||
# 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
|
||||
if (Test-Connection -ComputerName $BackupDestination -Count 1) {
|
||||
# If so, get the filesystem path
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#region Module Import Block
|
||||
|
||||
$ErrorActionPreference = 'SilentlyContinue'
|
||||
#$ErrorActionPreference = 'SilentlyContinue'
|
||||
#DevStage can take either Dev or Prod as values
|
||||
$devStage = 'Dev'
|
||||
#Locations for dev build and prod build
|
||||
|
|
@ -53,7 +53,6 @@ Function Get-PC {
|
|||
-PCReboot | reboots computer
|
||||
-PCRename | renames computer
|
||||
-RemoteDesktopApp | remote into computer using RDP
|
||||
-RequestLauncher | starts request launcher
|
||||
-ResetRepository | remotely resets repository
|
||||
-Resources | more details about system resources
|
||||
-PrinterPurge | removes printer from all online computers
|
||||
|
|
@ -104,7 +103,6 @@ Function Get-PC {
|
|||
[Switch]$PCRename,
|
||||
[Switch]$Quiet,
|
||||
[Switch]$RemoteDesktopApp,
|
||||
[Switch]$RequestLauncher,
|
||||
[Switch]$Resources,
|
||||
[Switch]$ResetRepository,
|
||||
[Switch]$PrinterPurge,
|
||||
|
|
@ -127,445 +125,405 @@ Function Get-PC {
|
|||
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'
|
||||
}
|
||||
# Stuff only run once
|
||||
if ($Update) {
|
||||
#updates get pc
|
||||
Update-GetPC
|
||||
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
|
||||
$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) {
|
||||
#Pulls user data from AD
|
||||
if ($SHSUser) {
|
||||
$user = Get-SHSUser $comp
|
||||
$outPutArray += $user
|
||||
continue
|
||||
}
|
||||
|
||||
$NumberofComputers = $ComputerName.Count
|
||||
foreach ($comp in $ComputerName) {
|
||||
$oldcomp = $comp
|
||||
$comp,$msg = Get-Hostname $comp
|
||||
if ($msg) {
|
||||
Write-Host "`n$msg" -ForegroundColor Red
|
||||
|
||||
if ($PatchNotes) {
|
||||
$scriptparent = (get-item $PSScriptRoot ).parent.FullName
|
||||
Write-Host "`n"
|
||||
Get-Content $scriptparent\patchnotes.txt
|
||||
break
|
||||
$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
|
||||
|
||||
#Pulls user data from AD
|
||||
if ($SHSUser) {
|
||||
$user = Get-SHSUser $comp
|
||||
$outPutArray += $user
|
||||
continue
|
||||
}
|
||||
$outPutArray += $obj
|
||||
|
||||
$oldcomp = $comp
|
||||
$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) {
|
||||
$msg = "$comp Asset Tag not in SMBIOS or CMDB"
|
||||
Write-Host "`n$msg" -ForegroundColor Red
|
||||
continue
|
||||
}
|
||||
|
||||
#DREW SUCKS
|
||||
|
||||
#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
|
||||
|
||||
#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'
|
||||
if ($TableView) {
|
||||
$out | Out-GridView -Title "Workstations Associated with $comp"
|
||||
}
|
||||
else {
|
||||
$compStatus = 'Offline'
|
||||
Write-Output $out
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
#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
|
||||
if ($PrinterPurge) {
|
||||
Invoke-PrinterPurge $comp
|
||||
continue
|
||||
}
|
||||
|
||||
#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 {
|
||||
$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++
|
||||
#grabs info on attached monitors and usb devices
|
||||
if ($Devices) {
|
||||
ProgressBar -CurrentPC $comp -NumberofComputers $NumberofComputers -Percent $PCID -CurrentLocationText 'Devices' -CurrentPCNumber $PCID
|
||||
$PCID++
|
||||
|
||||
if ($compStatus -ne 'Online') {
|
||||
Write-Warning "$comp is $compStatus skipping monitor query"
|
||||
}
|
||||
if ($compStatus -ne 'Online') {
|
||||
Write-Warning "$comp is $compStatus skipping monitor query"
|
||||
}
|
||||
|
||||
$out = Get-Devices $comp $compStatus
|
||||
if ($null -eq $out) {
|
||||
Write-Warning "Unable to get device info for $comp"
|
||||
continue
|
||||
}
|
||||
|
||||
$outPutArray += $out
|
||||
$out = Get-Devices $comp $compStatus
|
||||
if ($null -eq $out) {
|
||||
Write-Warning "Unable to get device info for $comp"
|
||||
continue
|
||||
}
|
||||
|
||||
#Pulls the event log for the past x days
|
||||
if ($EventLog) {
|
||||
$outPutArray += $out
|
||||
continue
|
||||
}
|
||||
|
||||
if ($compStatus -ne 'Online') {
|
||||
Write-Warning "$comp is $compStatus unable to proccess command"
|
||||
break
|
||||
}
|
||||
#Pulls the event log for the past x days
|
||||
if ($EventLog) {
|
||||
|
||||
Get-PCEventLog $comp
|
||||
if ($compStatus -ne 'Online') {
|
||||
Write-Warning "$comp is $compStatus unable to proccess command"
|
||||
break
|
||||
}
|
||||
|
||||
#Will remove selected users profile from C:\Users\ and cleans the registry of their profile
|
||||
if ($WinProfileRebuild) {
|
||||
Get-PCEventLog $comp
|
||||
break
|
||||
}
|
||||
|
||||
if ($compStatus -ne 'Online') {
|
||||
Write-Warning "$comp is $compStatus unable to proccess command"
|
||||
break
|
||||
}
|
||||
#Will remove selected users profile from C:\Users\ and cleans the registry of their profile
|
||||
if ($WinProfileRebuild) {
|
||||
|
||||
Get-WinProfileRebuild $comp
|
||||
if ($compStatus -ne 'Online') {
|
||||
Write-Warning "$comp is $compStatus unable to proccess command"
|
||||
break
|
||||
}
|
||||
|
||||
if ($ResetRepository) {
|
||||
Get-WinProfileRebuild $comp
|
||||
break
|
||||
}
|
||||
|
||||
if ($compStatus -ne 'Online') {
|
||||
Write-Warning "$comp is $compStatus unable to proccess command"
|
||||
break
|
||||
}
|
||||
if ($ResetRepository) {
|
||||
|
||||
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
|
||||
if ($compStatus -ne 'Online') {
|
||||
Write-Warning "$comp is $compStatus unable to proccess command"
|
||||
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
|
||||
}
|
||||
Get-ResetRepository $comp
|
||||
continue
|
||||
}
|
||||
|
||||
if ($AppDiff) {
|
||||
Get-AppDiff $comp $TableView
|
||||
continue
|
||||
}
|
||||
#Backs up user profile to specified destination
|
||||
if ($UserProfileBackup) {
|
||||
|
||||
if ($UninstallProgram) {
|
||||
Invoke-UninstallProgram $comp
|
||||
if ($compStatus -ne 'Online') {
|
||||
Write-Warning "$comp is $compStatus unable to proccess command"
|
||||
break
|
||||
}
|
||||
|
||||
if ($GPUpdate) {
|
||||
Get-UserProfileBackup $comp
|
||||
break
|
||||
}
|
||||
|
||||
if ($compStatus -ne 'Online') {
|
||||
Write-Warning "$comp is $compStatus unable to proccess command"
|
||||
break
|
||||
}
|
||||
#Remotely renames and restarts the computer.
|
||||
if ($PCRename) {
|
||||
|
||||
Get-GPUpdate $comp
|
||||
if ($compStatus -ne 'Online') {
|
||||
Write-Warning "$comp is $compStatus unable to proccess command"
|
||||
break
|
||||
}
|
||||
|
||||
#Will not notify the user that another user is about to remote onto their PC
|
||||
if ($Bypass) {
|
||||
Get-PCRename $comp
|
||||
break
|
||||
}
|
||||
|
||||
if ($compStatus -ne 'Online') {
|
||||
Write-Warning "$comp is $compStatus unable to proccess command"
|
||||
break
|
||||
}
|
||||
#removes temp, cache files, and inactive user profiles
|
||||
if ($PCCleanup) {
|
||||
|
||||
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
|
||||
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
|
||||
if ($compStatus -ne 'Online') {
|
||||
Write-Warning "$comp is $compStatus unable to proccess command"
|
||||
break
|
||||
}
|
||||
|
||||
#Same as C$ into a workstation
|
||||
if ($FileSystem) {
|
||||
Get-PCCleanup $comp
|
||||
Get-PCProfileCleanup $comp
|
||||
break
|
||||
}
|
||||
|
||||
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
|
||||
#Will reboot the users selected PC
|
||||
if ($PCReboot) {
|
||||
if ($compStatus -ne 'Online') {
|
||||
Write-Warning "$comp is $compStatus unable to proccess command"
|
||||
break
|
||||
}
|
||||
|
||||
if ($InstallNet35) {
|
||||
Get-InstallNet35 $comp
|
||||
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 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
|
||||
}
|
||||
|
||||
#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)
|
||||
Get-FileSystem $comp
|
||||
continue
|
||||
}
|
||||
|
||||
#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 }
|
||||
#Will log off the current logged in user for the designated PC
|
||||
#Adapted from Josh Gobens Logoff Script
|
||||
if ($LogOffUser) {
|
||||
|
||||
if ($adTest) {
|
||||
Write-Warning "$comp is either disabled or off the domain"
|
||||
}
|
||||
Write-Progress -Activity "Looking up computer in AD" -Completed
|
||||
if ($compStatus -ne 'Online') {
|
||||
Write-Warning "$comp is $compStatus unable to proccess command"
|
||||
break
|
||||
}
|
||||
|
||||
#Direct SCCM Queries
|
||||
if ( $SCCM ) {
|
||||
$result = Get-SCCMQuery $comp $NumberofComputers $PCID
|
||||
$PCID++
|
||||
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"
|
||||
}
|
||||
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
|
||||
#$getPCComputers += $comp
|
||||
}
|
||||
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