Monday, April 21, 2014

Remote DNS Check

In moving our data center the request was made to identify all servers with static IP's that had DNS entries of servers that we were being decommissioned.
This is what I used -
param( 
  [parameter(ValueFromPipeline=$TRUE)] 
    [String[]] $ComputerName=$Env:COMPUTERNAME, 
    [System.Management.Automation.PSCredential] $Credential 
) 
 
begin { 
  $PipelineInput = (-not $PSBOUNDPARAMETERS.ContainsKey("ComputerName")) -and (-not $ComputerName) 
 
  # Outputs the computer name, IP address, and DNS and WINS settings for 
  # every IP-enabled adapter on the specified computer that's configured with 
  # an IPv4 address. 
  function Get-IPInfo($computerName) { 
    $params = @{ 
      "Class" = "Win32_NetworkAdapterConfiguration" 
      "ComputerName" = $computerName 
      "Filter" = "IPEnabled=True" 
    } 
    if ( $Credential ) { $params.Add("Credential", $Credential) } 
    get-wmiobject @params | foreach-object { 
      foreach ( $adapterAddress in $_.IPAddress ) { 
        if ( $adapterAddress -match '(\d{1,3}\.){3}\d{1,3}' ) { 
          foreach ( $dnsServerAddress in $_.DNSServerSearchOrder ) { 
            new-object PSObject -property @{ 
              "ComputerName" = $_.__SERVER 
              "IPAddress" = $adapterAddress 
              "DNSServer" = $dnsServerAddress 
            } | select-object ComputerName,IPAddress,DNSServer 
          } 
        } 
      } 
    } 
  } 
} 
 
process { 
  if ( $PipelineInput ) { 
    Get-IPInfo $_ 
  } 
  else { 
    $ComputerName | foreach-object { 
      Get-IPInfo $_ 
    } 
  } 
}

1 comment:

  1. Best casino bonus codes 2021 - CasinoWow
    Top Online Casino Bonuses for 2021 · 1. febcasino Spin for Free · 2. 1xBet 1xbet korean Casino Bonus · 3. Virgin Casino 인카지노 Bonus · 4. Bovegas Casino Bonus · 5. Bovada

    ReplyDelete

Remote Mailboxes - Hybrid Config - Missing

The Remote Mailbox exists on the On Prem Exchange server and linked to the Office 365 mailbox. Without one of these for each Office 365 mail...