Powershell command to get list of storage groups which has Circularlogging enabled
Get-StorageGroup |?{$_.CircularLoggingEnabled -eq $True}| select server,AdminDisplayName,CircularLoggingEnabled
Powershell command to get list of storage groups which has Circularlogging enabled
Get-StorageGroup |?{$_.CircularLoggingEnabled -eq $True}| select server,AdminDisplayName,CircularLoggingEnabled
Powershell to check if set of users for security security permission. Below script helps to check if users has Account Operators listed in security permission
$csv = Import-csv -path "D:\Krishna\dsacls\user.csv"foreach($line in $csv){$input = "\\Servername\" + $line.DN$K = .\dsacls.exe $input$i = 1foreach ($service in $K){$Status = $service -like "Allow BUILTIN\Account Operators*"if ($status -eq $true){i= 0}}if($i -eq 1){$line.mailnickname >> dcalsresult.txt}
You can also find the copy in the below link
http://powershell.com/cs/members/smtpport25.wordpress/files/UserSecurityPermission.ps1.aspx
$servers=get-content c:\servers.txt
$services=”dhcp”
foreach($server in $servers){
$result=gwmi -computer $server win32_service
foreach($service in $services){
$result|where{$_.name -eq $service} | Select name, state
}
}
Please find my Presentation file on Windows Powershell scripting presented Community Tech Days 2010
I will be presenting Windows Powershell Scripting and new features of Powershell 2.0 and Exchange 2010 HA Demo
Register at http://Bitpro.in
Powershell to Add A record and MX record into DNS. Add all the values which are given in <>
$ServerName = <DNS ServerName>
$MXrec = [WMIClass]”\\$ServerName\root\MicrosoftDNS:MicrosoftDNS_MXType”
$server = “<DNSservername>”
$OwnerName = “<domain.Example>”
$ContainerName “<domain.Example>”
$RecordClass = $Null
$TTL = $Null
$Preference = 10
$MailExchange = “mail.domain.Example”
$$MXrec.CreateInstanceFromPropertyData($ServerName, $ContainerName,’
$OwnerName, $RecordClass, $TTL, $Preference, $MailExchange
$Arec = [WmiClass]”\\$ServerName\root\MicrosoftDNS:MicrosoftDNS_AType”
$server = “<DNSservername>”
$zone = “<zoneName>”
$name = “ArecordServerAddress”
$class = 1
$ttl = 3600
$address = “IPAddress”
$Arec.CreateInstanceFromPropertydata($server, $zone, $name, $class,’
$ttl, $address)
Below Powershell helps to ping given set of ip address and get the result status and also provides the status of number of machines which are rechable
$ping = New-Object System.Net.NetworkInformation.Ping
$i = 0
1..255 | foreach { $ip = “192.168.1.$_”
$Res = $ping.send($ip)
if ($Res.Status -eq “Success”)
{
$result = $ip + ” = Success”
Write-Host $result
$i++
}
$Hosts = [string]$i + ” Hosts is pingable”
Write-Host $Hosts
In Exchange 2007 We have may have lots of DBs which we land up in creating multiple mount points instead of Drives for each Logs and Database. Below script helps to pull out the size and free size of all the mount point of the database . Change the servername and for loop with the number of Database you have.
$K = gwmi win32_volume -computername “Servername” |where-object {$_.name -like “C:\Mountpoints\DB*”}|select name,capacity,freespace
for ($i=0; $i -le 22; $i++)
{
$name = $K[$i].name
$Capacity = [math]::truncate($K[$i].capacity/1gb)
$freespace = [math]::truncate($K[$i].freespace/1gb)
$L = $name + ” ” + $Capacity + ” ” + $freespace
write-output $L
}
Need to make sure that PortQry is downloaded from the microsoft site and use below powershell script to check the same
$Servername = Read-Host “Enter the Servername”
$PortNumber = Read-Host “Enter the Port Number”
$K = .\PortQry.exe -n $Servername -e $PortNumber -p TCP
$L = $K -Match “LIS?”
If($L -ne $null)
{
$res = $servername + ” has ” + $PortNumbe + “Opened”
Write-Host $res
}
Else
{
$res = $servername + ” has ” + $PortNumbe + “Closed”
Write-Host $res
}
Below powershell helps to pull out all the secondary email address for the given set of users
Get-Content C:\users.txt|Get-Mailbox | foreach {
for ($i=$_.EmailAddresses.Count;$i -ge 0; $i–)
{
$_.EmailAddresses[$i].ProxyAddressString
if ($_.EmailAddresses[$i].ProxyAddressString -like “smtp:*” )
{
$_.EmailAddresses.RemoveAt($i)
}
}
$_|set-mailbox
}