Wednesday, April 30, 2014

Excel - Format Data Cell for kb/mb/gb

Have you ever exported a powershell script only to see values like 876755433?

Have you ever wanted an easy way to format that number auto-magically into a kb's mb's or gb's?

Use the following process:

In Excel
Select the column needed to format
Right click column header
Choose "Format Cells"
Choose the "Custom" option under the "Number" tab
Paste this value - [<1000]#,##0.00" KB ";[<1000000]#,##0.00," MB";#,##0.00,," GB"
And click OK


MAGIC!

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 $_ 
    } 
  } 
}

Gather all 5 FSMO Roles with Powershell

<#
This simple script will pole your domain for the 5 FSMO roles
#>
import-module activedirectory
$fqdn = Read-Host 'Domain Name'
$forest = get-adforest $fqdn | Format-Table SchemaMaster,DomainNamingMaster
$domain = get-addomain $fqdn | Format-Table PDCEmulator,RIDMaster,InfrastructureMaster
$info = $forest,$domain
$info

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...