PowerShell script to find network info for all NICs on a list of Windows servers

### PowerShell script to find for all NICs on a Windows server : IP address, Subnet Mask, Gateway, if DHCP is enabled, DNS servers, WINS servers
# This works on a given list of servers, and collects info for all NICs of server.
###############################################################################

$outputfile = “D:\temp\Networkinfo-4.csv”
$servers = get-content “D:\temp\test2.txt”
$report = @()

foreach ($Computer in $servers)
{
if(Test-Connection -ComputerName $Computer -Count 1 -ea 0)
{
$Networks = $null
$Networks = Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName $Computer -ea silentlycontinue | ? {$_.IPEnabled}

if($Networks)
{
foreach ($Network in $Networks)
{
$IPAddress = $null
$SubnetMask = $null
$DefaultGateway= $null
$DNSServers = $null
$WINSPrimaryserver = $null
$WINSSecondaryserver = $null
$IsDHCPEnabled = $null

$IPAddress = $Network.IpAddress[0]
$SubnetMask = $Network.IPSubnet[0]
$DefaultGateway = $Network.DefaultIPGateway -join ‘,’
$DNSServers = $Network.DNSServerSearchOrder -join ‘,’
$WINSPrimaryserver = $Networks.WINSPrimaryServer
$WINSSecondaryserver = $Networks.WINSSecondaryserver
$IsDHCPEnabled = $false

If($network.DHCPEnabled) { $IsDHCPEnabled = $true }

$OutputObj = New-Object -Type PSObject
$OutputObj | Add-Member -MemberType NoteProperty -Name ComputerName -Value $Computer.ToUpper()
$OutputObj | Add-Member -MemberType NoteProperty -Name IPAddress -Value $IPAddress
$OutputObj | Add-Member -MemberType NoteProperty -Name SubnetMask -Value $SubnetMask
$OutputObj | Add-Member -MemberType NoteProperty -Name Gateway -Value $DefaultGateway
$OutputObj | Add-Member -MemberType NoteProperty -Name IsDHCPEnabled -Value $IsDHCPEnabled
$OutputObj | Add-Member -MemberType NoteProperty -Name DNSServers -Value $DNSServers
$OutputObj | Add-Member -MemberType NoteProperty -Name WINSPrimaryserver -Value $WINSPrimaryserver
$OutputObj | Add-Member -MemberType NoteProperty -Name WINSSecondaryserver -Value $WINSSecondaryserver

$OutputObj
$report += $OutputObj

} # foreach ends here
} # if Networks ends here
else { Write-Warning “Could not find any info on networks/NICs on server $Computer” }

} #if ping ends here
else { Write-Warning “Unable to access/ping $Computer” }

}

$report | Export-Csv $outputfile -NoClobber -NoTypeInformation

###############################################################################

Advertisements

PowerShell script to find all IP addresses assigned on a list of Windows Servers

### PowerShell script to find all IP addresses assigned on a list of Windows Servers.
### List all IP addresses assigned in each server, includes IPv6
###############################################################################

$servers = Get-Content “D:\temp\test2.txt”
$reg=””
foreach ($server in $servers)
{
$reg+=$server+ “`t”+([System.Net.Dns]::GetHostAddresses(“$server”) | foreach {echo $_.IPAddressToString})+”`n”
}
$reg > “D:\temp\ping-IPs-1.csv”

PowerShell script to find FQDN and get ping status of Windows Servers

### PowerShell script to find FQDN and get ping status for given list of windows servers
# Servers which we failed to connect to get any info are collected in to a txt file.
### Writing credits : VM ###
###########################################################################

$servers = Get-Content “D:\temp\test2.txt”

@(
foreach ($name in $servers)
{
if ( Test-Connection -ComputerName “$name.domain.com” -Count 1 -ErrorAction SilentlyContinue ) { Write-output “$name.domain.com is up”}
elseif ( Test-Connection -ComputerName “$name.a.domain.com” -Count 1 -ErrorAction SilentlyContinue ) { Write-output “$name.a.domain.com is up”}
elseif ( Test-Connection -ComputerName “$name.b.domain.com” -Count 1 -ErrorAction SilentlyContinue ) { Write-output “$name.b.domain.com is up”}
elseif ( Test-Connection -ComputerName “$name.c.domain.com” -Count 1 -ErrorAction SilentlyContinue ) { Write-output “$name.c.domain.com is up”}
elseif ( Test-Connection -ComputerName “$name.newdomain.com” -Count 1 -ErrorAction SilentlyContinue ) { Write-output “$name.newdomain.com is up”}
#elseif ( Test-Connection -ComputerName “$name” -Count 1 -ErrorAction SilentlyContinue ) { Write-output “$name is up”}
else
{
Write “$name FQDN not found/ server is not pinging” | out-file -Append “D:\temp\failed-ping-1.txt” -NoClobber
}
}
) | Out-file -FilePath “D:\temp\FQDN-1.csv”

PowerShell script to find a server is physical server or virtual machine

### Powershell script gives Manufacturer and Server Model for a given list of servers, and we can find if its a VM or a physical server.
### eg: for a VM, manufacturer will be “VMware, Inc.”, and model will be “VMware Virtual Platform”
### eg: for a physical server, manufacturer will be “HP” (or others), and model will be “ProLiant BL460c G7”
### Servers which we failed to connect to get any info are collected in to a txt file.
### writing credits : VM ###
#######################################################################################

$servers = Get-Content “D:\temp\test2.txt”
$result = @()
$finalresult = @()

foreach ($computer in $servers)
{
$result = Get-WmiObject -Class Win32_ComputerSystem -ComputerName $computer | select pscomputername, manufacturer, model
$finalresult+=$result
if (!$result) { Write “No info on server $computer” | out-file -Append “D:\temp\notfound-phy-vm.txt” -NoClobber }
$computer = $null
$result = $null
}

$finalresult | export-csv “D:\temp\VMphys-1.csv” -NoTypeInformation

PowerShell script to find OS name, Service Pack Version and OS-Architecture (32/64 bit)

### PowerShell script to find OS name, Service Pack Version and OS-Architecture (32/64 bit) for given list of servers
# servers which we failed to connect to get any info are collected in to a txt file
### writing credits : VM ###
#######################################################################################

$servers = Get-Content “D:\temp\test2.txt”
$result = @()
$finalresult = @()

foreach ($srv in $servers)
{
$result = Get-WMIObject Win32_OperatingSystem -ComputerName $srv | Select-Object csname, caption, ServicePackMajorVersion, OSArchitecture
$finalresult+=$result
if (!$result) { Write “No info on server $srv” | out-file -Append “D:\temp\notfound.txt” -NoClobber }
$srv = $null
$result = $null
}

$finalresult | export-csv “D:\temp\OS-outputs.csv” -NoTypeInformation

How to find MTU on a list of Windows Servers, using PowerShell ?

# This script can be used to find MTU size on a list of servers. Choose FQDN or make sure all servers are accessible using server name. # Get-NetIPInterface  is part of PowerShell module NetTCPIP, and should work for all servers with PowerShell v3+, though this is not tested.# Any errors will be displayed in the console window.

$servers = Get-Content "D:\temp\all-servers.txt
@(
foreach ($name in $servers) 
{ 
 if ( Test-Connection -ComputerName $name -Count 1 -ErrorAction SilentlyContinue )
 {
 $var1 = New-PSSession -ComputerName $name
 Invoke-Command -Session $var1 -ScriptBlock { Get-NetIPInterface | where {($_.AddressFamily -eq "IPv4") -and ($_.NlMtu -lt 10000)} | select NlMtu, interfacealias, pscomputername } | ft -a
 #Invoke-Command -Session $var1 -ScriptBlock { netsh interface ipv4 show subinterface} | fl *       #we can use this line using netsh as an alternative to the invoke-command in the above line
 sleep 5
 $var1 | Remove-PSSession #this will remove/close all existing ps sessions
 $var1 = $null
 }
 else
 {
 Write "$name is not pinging/not accessible"
 }
}) | out-file "D:\temp\MTU-all-servers-1.csv"

#script ends here#

Licensing for SQL Server 2012

http://www.mssqltips.com/sqlservertip/2942/understanding-the-sql-server-2012-licensing-model/

http://sqlmag.com/sql-server-2012/sql-server-2012-editions

Editions and Components of SQL Server 2012

http://technet.microsoft.com/en-us/library/ms144275.aspx

Compute Capacity Limits by Edition of SQL Server

http://technet.microsoft.com/en-us/library/ms143760.aspx

Features Supported by the Editions of SQL Server 2012

http://technet.microsoft.com/en-us/library/cc645993.aspx