Windows services status in HTML format

$Style = ”
TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}
TH{border-width: 1px;padding: 3px;border-style: solid;border-color: black;}
TD{border-width: 1px;padding: 3px;border-style: solid;border-color: black;}

$GService = Get-WmiObject win32_service | select name,DisplayName,state,startname,startmode | ConvertTo-HTML -AS Table -Fragment -PreContent ‘

Services status

$StatusColor = @{Stopped = ‘ bgcolor=”RED”>Stopped<‘;Running = ‘ bgcolor=”Green”>Running<‘;}
$StatusColor.Keys | foreach { $GService = $GService -replace “>$_<“,($StatusColor.$_) }

#Save the HTML Web Page
ConvertTo-HTML -head $Style -PostContent $GService|Out-File c:\temp\TableHTML.html

#Open TableHTML.html
Invoke-Item c:\temp\TableHTML.html

Get-WmiObject win32_service | ft name, startname,startmode

Start the services via PS

Get-Service Wsearch | Where {$_.status –eq ‘Stopped’} | Start-Service

get-service bits,wsearch,winrm,spooler | where {$_.status -eq ‘running’} | stop-service -whatif

AD Partitions backup status

PasswordExpiry date

Get-ADUser -filter * -Properties msDS-UserPasswordExpiryTimeComputed | select name,@{Name=”PasswordExpiryDate”;Expression={[datetime]::FromFileTime($_.”msDS-UserPasswordExpiryTimeComputed”)}}

Start specific services bulk machines

$Service_name  = “Browser”, “RpcSs” , “RemoteRegistry”

$computer = Get-Content C:\Users\lvbgsmc\Desktop\Servers.txt

Get-Service -ComputerName $computer -Name $Service_name | Start-Service

Start services remotelly

$Service_name = “RemoteRegistry”
$computer = Get-Content C:\Users\lvbgsmc\Desktop\Servers.txt

Get-Service -ComputerName $computer -Name $Service_name | Start-Service

AD replication health check PS command

Get-ADReplicationPartnerMetadata -Target * -Partition * | Select-Object Server,Partition,Partner,
ConsecutiveReplicationFailures,LastReplicationSuccess,LastRepicationResult | Out-GridView

Reporting on Inactive Users in Active Directory

# 30 days not login users list

Import-Module ActiveDirectory
Search-ADAccount -UsersOnly -AccountInactive -TimeSpan 30.00:00:00 |where {$_.enabled} | Export-CSV –path C:\Temp\InactiveUsers.csv

Unlock the account

Import-Module activ*
Unlock-ADAccount -Identity “CN=Test11,OU=Int_Out,OU=Bathinda,OU=Geographical,DC=hmel,DC=int”


# A quick replication health report
repadmin /showrepl * /csv | ConvertFrom-CSV | Out-GridView

# Replication health for a site
repadmin /showrepl * /csv | ConvertFrom-CSV |
Where-Object {$_.”Source DSA Site” -eq “Ohio”} | Out-GridView

# Replication health grouped by naming context (database partition)
repadmin /showrepl * /csv | ConvertFrom-CSV |
Sort-Object “Naming Context” | Format-Table -GroupBy “Naming Context”

%d bloggers like this: