Made get-pc somewhat pipeline friendly
This commit is contained in:
parent
a1c8bc0f74
commit
c039beac33
|
|
@ -8,6 +8,14 @@ Function Get-SCCMQueryBlock {
|
||||||
$SITENAME="100"
|
$SITENAME="100"
|
||||||
$SCCMSERVER="shscm01.int.samhealth.net"
|
$SCCMSERVER="shscm01.int.samhealth.net"
|
||||||
$SCCMNAMESPACE="root\sms\site_100"
|
$SCCMNAMESPACE="root\sms\site_100"
|
||||||
|
# Spark connection params
|
||||||
|
$Tenant = 'https://samaritanhealth-amc.ivanticloud.com'
|
||||||
|
$Headers = @{
|
||||||
|
"Content-Type" = "application/json"
|
||||||
|
"Authorization" = 'rest_api_key=EB68123D62F8489295C807353C92D75B'
|
||||||
|
"Accept" = "*/*"
|
||||||
|
"Accept-Encoding" = "gzip, deflate, br"
|
||||||
|
}
|
||||||
|
|
||||||
if(!(Test-Connection -ComputerName $comp -Count 1)){
|
if(!(Test-Connection -ComputerName $comp -Count 1)){
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ Function Get-PC {
|
||||||
-LogOffUser | remotely logs off user
|
-LogOffUser | remotely logs off user
|
||||||
-Monitor | monitors computers for changes in status
|
-Monitor | monitors computers for changes in status
|
||||||
-NextPrinterName | generates next open printer name
|
-NextPrinterName | generates next open printer name
|
||||||
|
-NoResolve | skips hostname resolution, assumes provided name is a hostname
|
||||||
-Orion | opens orion to the mac address of the pc
|
-Orion | opens orion to the mac address of the pc
|
||||||
-PatchNotes | read the patch notes
|
-PatchNotes | read the patch notes
|
||||||
-PCCleanup | removes temp files and inactive user profiles
|
-PCCleanup | removes temp files and inactive user profiles
|
||||||
|
|
@ -129,6 +130,7 @@ Function Get-PC {
|
||||||
[Switch]$LogOffUser,
|
[Switch]$LogOffUser,
|
||||||
[Switch]$Monitor,
|
[Switch]$Monitor,
|
||||||
[Switch]$NextPrinterName,
|
[Switch]$NextPrinterName,
|
||||||
|
[Switch]$NoResolve,
|
||||||
[switch]$Orion,
|
[switch]$Orion,
|
||||||
[Switch]$PatchNotes,
|
[Switch]$PatchNotes,
|
||||||
[Switch]$PCCleanup,
|
[Switch]$PCCleanup,
|
||||||
|
|
@ -153,6 +155,7 @@ Function Get-PC {
|
||||||
[Switch]$WinProfileRebuild
|
[Switch]$WinProfileRebuild
|
||||||
)
|
)
|
||||||
|
|
||||||
|
begin {
|
||||||
#Data collection for Get-PC Wrapped TM
|
#Data collection for Get-PC Wrapped TM
|
||||||
$invokeData = @{
|
$invokeData = @{
|
||||||
Hostname = $env:COMPUTERNAME
|
Hostname = $env:COMPUTERNAME
|
||||||
|
|
@ -257,8 +260,10 @@ Function Get-PC {
|
||||||
|
|
||||||
$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 = 0 #This is a helper variable for the progress bar
|
|
||||||
|
|
||||||
|
} process {
|
||||||
|
|
||||||
|
$PCID = 0 #This is a helper variable for the progress bar
|
||||||
$NumberofComputers = $ComputerName.Count
|
$NumberofComputers = $ComputerName.Count
|
||||||
foreach ($comp in $ComputerName) {
|
foreach ($comp in $ComputerName) {
|
||||||
$PCID++
|
$PCID++
|
||||||
|
|
@ -270,7 +275,9 @@ Function Get-PC {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
$comp,$msg = Get-Hostname $comp
|
if (-not ($NoResolve)) {
|
||||||
|
$comp,$msg = Get-Hostname $comp
|
||||||
|
}
|
||||||
Write-Progress -Activity "Get-PC flags processing" -Status "$comp ($PCID/$NumberofComputers)" -PercentComplete ($PCID*100/$NumberOfComputers) -Id 1
|
Write-Progress -Activity "Get-PC flags processing" -Status "$comp ($PCID/$NumberofComputers)" -PercentComplete ($PCID*100/$NumberOfComputers) -Id 1
|
||||||
if ($msg -and -not $SHSPrinter) {
|
if ($msg -and -not $SHSPrinter) {
|
||||||
if ($SoundEnabled) {
|
if ($SoundEnabled) {
|
||||||
|
|
@ -678,6 +685,8 @@ Function Get-PC {
|
||||||
}
|
}
|
||||||
Write-Progress -Activity "Get-PC flags processing" -Completed -Id 1
|
Write-Progress -Activity "Get-PC flags processing" -Completed -Id 1
|
||||||
|
|
||||||
|
} end {
|
||||||
|
|
||||||
# Monitor list of PCs for change in online status or
|
# Monitor list of PCs for change in online status or
|
||||||
if ($Monitor) {
|
if ($Monitor) {
|
||||||
Invoke-PCMonitor $getPCComputers
|
Invoke-PCMonitor $getPCComputers
|
||||||
|
|
@ -714,4 +723,6 @@ Function Get-PC {
|
||||||
ExportToExcel $outPutArray
|
ExportToExcel $outPutArray
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} #end
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue