4848
4949 . NOTES
5050 Author: Blake Drumm
51- Version: 1.3
51+ Version: 1.4
5252 Created: November 17th, 2023
5353 Modified: March 18th, 2024
5454#>
@@ -157,6 +157,11 @@ function Invoke-SCXWinRMEnumeration
157157 $EnumerateAllClasses = $true
158158 }
159159
160+ if (-NOT $OriginServer )
161+ {
162+ $OriginServer = $locallyResolvedName
163+ }
164+
160165 $results = @ ()
161166
162167 foreach ($ServerName in $ComputerName )
@@ -181,14 +186,17 @@ function Invoke-SCXWinRMEnumeration
181186 {
182187 foreach ($class in $scxClasses )
183188 {
184- if (-NOT $PassThru )
185- {
186- Write-Host " Enumerating: $class " - ForegroundColor Cyan
187- }
188189 $result = if ($Credential )
189190 {
190191 foreach ($origin in $OriginServer )
191192 {
193+ if (-NOT $PassThru )
194+ {
195+ Write-Host " Enumerating: $class " - ForegroundColor Cyan - NoNewline
196+ Write-Host " (Origin server: " - NoNewline
197+ Write-Host " $origin " - ForegroundColor DarkYellow - NoNewline
198+ Write-Host " )"
199+ }
192200 $resolvedName = (Resolve-DnsName $origin ).Name | Select-Object - Unique - Index 0
193201 if ($resolvedName -eq " $locallyResolvedName " )
194202 {
@@ -221,7 +229,9 @@ function Invoke-SCXWinRMEnumeration
221229 }
222230 }
223231
224- return $customObject
232+ $customObject | Add-Member - MemberType NoteProperty - Name PSComputerName - Value $locallyResolvedName
233+
234+ $customObject
225235 }
226236 else
227237 {
@@ -295,8 +305,9 @@ function Invoke-SCXWinRMEnumeration
295305 }
296306 }
297307 }
308+ $customObject | Add-Member - MemberType NoteProperty - Name PSComputerName - Value $locallyResolvedName
298309
299- return $customObject
310+ $customObject
300311 }
301312 else
302313 {
@@ -384,8 +395,9 @@ function Invoke-SCXWinRMEnumeration
384395 }
385396 }
386397 }
398+ $customObject | Add-Member - MemberType NoteProperty - Name PSComputerName - Value $locallyResolvedName
387399
388- return $customObject
400+ $customObject
389401 }
390402 else
391403 {
@@ -460,13 +472,14 @@ function Invoke-SCXWinRMEnumeration
460472 }
461473 }
462474 }
475+ $customObject | Add-Member - MemberType NoteProperty - Name PSComputerName - Value $locallyResolvedName
463476
464- return $customObject
477+ $customObject
465478 }
466479 else
467480 {
468481 Invoke-Command - ComputerName $resolvedName - ScriptBlock {
469- Write-Host " Origin Server = $env: COMPUTERNAME `n ServerName = $using :ServerName `n AuthenticationMethod = $using :AuthenticationMethod `n Credential = $using :Credential `n Class = $using :class "
482+ # Write-Host "Origin Server = $env:COMPUTERNAME`nServerName = $using:ServerName`nAuthenticationMethod = $using:AuthenticationMethod`nCredential = $using:Credential`nClass = $using:class"
470483 $out = Get-WSManInstance - ComputerName $using :ServerName - Authentication $using :AuthenticationMethod - Port 1270 - UseSSL - Enumerate " http://schemas.microsoft.com/wbem/wscim/1/cim-schema/2/$using :c `?__cimnamespace=root/scx" - ErrorAction Stop
471484 # Define properties to exclude
472485 $propertiesToExclude = @ (' ChildNodes' , ' LastChild' , ' OuterXml' , ' IsReadOnly' , ' SchemaInfo' , ' NodeType' , ' ParentNode' , ' OwnerDocument' , ' IsEmpty' , ' Attributes' , ' HasAttributes' , ' InnerText' , ' InnerXml' , ' BaseURI' , ' PreviousText' , ' FirstChild' , ' Value' , ' NextSibling' , ' PreviousSibling' , ' HasChildNodes' , ' RunspaceId' , ' xsi' )
0 commit comments