Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Write-Progress -Id 1 -Activity $MainScriptActivity -Status $MainScriptStatus -Pe
foreach ($user in $users)
{
$i++
Write-Progress -Id 2 -Activity $UserLoopActivity -Status "$i of $userCount - $user.Name" -PercentComplete ($i / $userCount * 100) -ParentId 1
Write-Progress -Id 2 -Activity $UserLoopActivity -Status "$i of $userCount - $($user.Name)" -PercentComplete ($i / $userCount * 100) -ParentId 1

$addresses = $user | Select-Object -ExpandProperty ProxyAddresses
If ($addresses)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ $file = ""
$csv = Import-Csv $file
foreach ($row in $csv) {
$IP = $row.SourceIP
$row.SourceName = ([System.Net.DNS]::GetHostbyAddress($IP)).Hostname
$row.SourceName = ([System.Net.DNS]::GetHostEntry($IP)).Hostname
}
$csv | Export-Csv "results.csv" -NoTypeInformation
7 changes: 5 additions & 2 deletions DDI/Resolve-IPs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ $ResultList = @()


foreach ($IP in $ListOfIPs) {
$ErrorActionPreference = 'silentlycontinue'
$Result = $null

Write-Host "Resolving $IP" -ForegroundColor Green
$result = [System.Net.Dns]::gethostentry($IP)
try {
$result = [System.Net.Dns]::gethostentry($IP)
} catch {
$result = $null
}
Comment thread
SamErde marked this conversation as resolved.

If ($Result) {
$ResultList += "$IP," + [string]$Result.HostName
Expand Down
18 changes: 9 additions & 9 deletions Snippets/RemoteServerSessionLoop2.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ foreach ($server in $servers) {

Try {
Write-Information "Connecting to $server... " -InformationAction Continue
Enter-PSSession $session
# Enter-PSSession is interactive-only; use Invoke-Command to run code in the remote session.
Invoke-Command -Session $session -ScriptBlock {
Comment thread
SamErde marked this conversation as resolved.
Outdated
<#
Code to be run on each remote server goes here.
#>
Write-Information 'Inner code.' -InformationAction Continue
}
} Catch {
Write-Warning "Failed to enter the PSSession for $server. Skipping." -WarningAction Continue
Write-Warning "Failed to connect to $server. Skipping." -WarningAction Continue
Continue
}
Write-Output $session.State
Comment thread
SamErde marked this conversation as resolved.
Outdated

<#
Code to be run on each remote server go here.
#>
Write-Information 'Inner code.' -InformationAction Continue

#Cleanup and then show the current PSSession state.
Exit-PSSession
Remove-PSSession $session
Write-Information "$session.ComputerName $session.State `n`n" -InformationAction Continue
Write-Information "$($session.ComputerName) $($session.State) `n`n" -InformationAction Continue
}
2 changes: 1 addition & 1 deletion Windows/Disable-Poshv2.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $exclusions = @('', '', '')
#Filtering out production servers as well as any SQL, Exchange, SharePoint (SPS), Telephony, rinf* servers, and any servers in the "Non Windows" OU.
$servers = (Get-ADComputer -Filter 'OperatingSystem -like "Windows Server*" -and Enabled -eq "True" -and Name -notlike "*sps*"' `
-SearchBase 'DC=DOMAIN,DC=COM' -SearchScope Subtree).Name | Where-Object { $_ -notin $Exclusions } | Sort-Object
Write-Information "$servers.Count servers found."
Write-Information "$($servers.Count) servers found."

foreach ($server in $servers) {
if (Test-WSMan -ComputerName $server -ErrorAction Ignore) {
Expand Down
Loading