Skip to content

Commit

Permalink
Update script - v1.4 🚆
Browse files Browse the repository at this point in the history
  • Loading branch information
blakedrumm authored Mar 19, 2024
1 parent 1890857 commit d3bdfb9
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions Powershell/Invoke-SCXWinRMEnumeration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
.NOTES
Author: Blake Drumm
Version: 1.3
Version: 1.4
Created: November 17th, 2023
Modified: March 18th, 2024
#>
Expand Down Expand Up @@ -157,6 +157,11 @@ function Invoke-SCXWinRMEnumeration
$EnumerateAllClasses = $true
}

if (-NOT $OriginServer)
{
$OriginServer = $locallyResolvedName
}

$results = @()

foreach ($ServerName in $ComputerName)
Expand All @@ -181,14 +186,17 @@ function Invoke-SCXWinRMEnumeration
{
foreach ($class in $scxClasses)
{
if (-NOT $PassThru)
{
Write-Host " Enumerating: $class" -ForegroundColor Cyan
}
$result = if ($Credential)
{
foreach ($origin in $OriginServer)
{
if (-NOT $PassThru)
{
Write-Host " Enumerating: $class" -ForegroundColor Cyan -NoNewline
Write-Host " (Origin server: " -NoNewline
Write-Host "$origin" -ForegroundColor DarkYellow -NoNewline
Write-Host ")"
}
$resolvedName = (Resolve-DnsName $origin).Name | Select-Object -Unique -Index 0
if ($resolvedName -eq "$locallyResolvedName")
{
Expand Down Expand Up @@ -221,7 +229,9 @@ function Invoke-SCXWinRMEnumeration
}
}

return $customObject
$customObject | Add-Member -MemberType NoteProperty -Name PSComputerName -Value $locallyResolvedName

$customObject
}
else
{
Expand Down Expand Up @@ -295,8 +305,9 @@ function Invoke-SCXWinRMEnumeration
}
}
}
$customObject | Add-Member -MemberType NoteProperty -Name PSComputerName -Value $locallyResolvedName

return $customObject
$customObject
}
else
{
Expand Down Expand Up @@ -384,8 +395,9 @@ function Invoke-SCXWinRMEnumeration
}
}
}
$customObject | Add-Member -MemberType NoteProperty -Name PSComputerName -Value $locallyResolvedName

return $customObject
$customObject
}
else
{
Expand Down Expand Up @@ -460,13 +472,14 @@ function Invoke-SCXWinRMEnumeration
}
}
}
$customObject | Add-Member -MemberType NoteProperty -Name PSComputerName -Value $locallyResolvedName

return $customObject
$customObject
}
else
{
Invoke-Command -ComputerName $resolvedName -ScriptBlock {
Write-Host "Origin Server = $env:COMPUTERNAME`nServerName = $using:ServerName`nAuthenticationMethod = $using:AuthenticationMethod`nCredential = $using:Credential`nClass = $using:class"
#Write-Host "Origin Server = $env:COMPUTERNAME`nServerName = $using:ServerName`nAuthenticationMethod = $using:AuthenticationMethod`nCredential = $using:Credential`nClass = $using:class"
$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
# Define properties to exclude
$propertiesToExclude = @('ChildNodes', 'LastChild', 'OuterXml', 'IsReadOnly', 'SchemaInfo', 'NodeType', 'ParentNode', 'OwnerDocument', 'IsEmpty', 'Attributes', 'HasAttributes', 'InnerText', 'InnerXml', 'BaseURI', 'PreviousText', 'FirstChild', 'Value', 'NextSibling', 'PreviousSibling', 'HasChildNodes', 'RunspaceId', 'xsi')
Expand Down

0 comments on commit d3bdfb9

Please sign in to comment.