Made get-pc somewhat pipeline friendly

This commit is contained in:
Zachary Gorman 2024-11-13 15:57:06 -08:00
parent a1c8bc0f74
commit c039beac33
2 changed files with 21 additions and 2 deletions

View file

@ -8,6 +8,14 @@ Function Get-SCCMQueryBlock {
$SITENAME="100"
$SCCMSERVER="shscm01.int.samhealth.net"
$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)){

View file

@ -73,6 +73,7 @@ Function Get-PC {
-LogOffUser | remotely logs off user
-Monitor | monitors computers for changes in status
-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
-PatchNotes | read the patch notes
-PCCleanup | removes temp files and inactive user profiles
@ -129,6 +130,7 @@ Function Get-PC {
[Switch]$LogOffUser,
[Switch]$Monitor,
[Switch]$NextPrinterName,
[Switch]$NoResolve,
[switch]$Orion,
[Switch]$PatchNotes,
[Switch]$PCCleanup,
@ -153,6 +155,7 @@ Function Get-PC {
[Switch]$WinProfileRebuild
)
begin {
#Data collection for Get-PC Wrapped TM
$invokeData = @{
Hostname = $env:COMPUTERNAME
@ -257,8 +260,10 @@ Function Get-PC {
$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 = 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
foreach ($comp in $ComputerName) {
$PCID++
@ -270,7 +275,9 @@ Function Get-PC {
continue
}
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
if ($msg -and -not $SHSPrinter) {
if ($SoundEnabled) {
@ -678,6 +685,8 @@ Function Get-PC {
}
Write-Progress -Activity "Get-PC flags processing" -Completed -Id 1
} end {
# Monitor list of PCs for change in online status or
if ($Monitor) {
Invoke-PCMonitor $getPCComputers
@ -714,4 +723,6 @@ Function Get-PC {
ExportToExcel $outPutArray
}
} #end
}