From c039beac33a8ddf57aa3d0d969b15dc6fa7847e5 Mon Sep 17 00:00:00 2001 From: Zachary Gorman Date: Wed, 13 Nov 2024 15:57:06 -0800 Subject: [PATCH] Made get-pc somewhat pipeline friendly --- Get-PC/Private/SCCMQueryBlock.ps1 | 8 ++++++++ Get-PC/Public/Get-PC.ps1 | 15 +++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Get-PC/Private/SCCMQueryBlock.ps1 b/Get-PC/Private/SCCMQueryBlock.ps1 index 7575731..4b467a6 100644 --- a/Get-PC/Private/SCCMQueryBlock.ps1 +++ b/Get-PC/Private/SCCMQueryBlock.ps1 @@ -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)){ diff --git a/Get-PC/Public/Get-PC.ps1 b/Get-PC/Public/Get-PC.ps1 index 6ebe2be..ebe5d8e 100644 --- a/Get-PC/Public/Get-PC.ps1 +++ b/Get-PC/Public/Get-PC.ps1 @@ -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 } - $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 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 @@ -713,5 +722,7 @@ Function Get-PC { if ($Excel) { ExportToExcel $outPutArray } + +} #end }