Wednesday, 24 February 2016

Testing purpose


$process= Get-Process -Name notepad -ComputerName server1

if($process)

{


schtasks /run /s dc.superdc.com /TN Service



}



else


{

Restart-Computer -Force -ComputerName server1

}





$process= Get-Process -Name notepad -ComputerName server2



if($process)

{


schtasks /run /s dc.superdc.com /TN Service



}



else


{

Restart-Computer -Force -ComputerName server2

}

Wednesday, 17 February 2016

Getting service status in HTML format and sending to mail

$a = "<style>"
$a = $a + "BODY{background-color:Green;}"
$a = $a + "TABLE{border-width: 2px;border-style: solid;border-color: black;border-collapse: collapse;}"
$a = $a + "TH{border-width: 2px;padding: 0px;border-style: solid;border-color: black;}"
$a = $a + "TD{border-width: 2;padding: 0px;border-style: solid;border-color: black;}"
$a = $a + "</style>"



$comp = Get-Content -Path C:\serverslist.txt

$m=foreach ($c in $comp)
{
Get-Service -ComputerName $comp | select-object machinename,Name,Status| Where-Object {$_.status -eq "running"} | ConvertTo-Html -head $a
}

Send-MailMessage -to "administrator@superdc.com"  -From "DG_ADMINS@superdc.com" -BodyAsHtml "$m" -Subject "Servicestatus" -SmtpServer "dc.superdc.com"

code in ISE

 I
output

Powershell function to get theremote server IP details,Subnetmask,Gateway,DHCP Enabled status,DNS Servers,Wins and Macaddress

#Powershell function to get theremote server IP details,Subnetmask,Gateway,DHCP Enabled status,DNS Servers,Wins and Macaddress # use...