Powershell – breaking a command down to multilines

So yeah .. I like things to be neat and clean and having a single line command in powershell is the norm for a lot of people. Example: New-MailContact -DomainController $dc -Name $alias.ContactName -ExternalEmailAddress $alias.ExternalEmailAddress -Alias $alias.ContactAlias -FirstName $alias.FirstName -Initials ” -LastName $alias.LastName -OrganizationalUnit $OU But like stated I like… Continue reading

Powershell to check Last Reboot on a Windows Server

Not sure I will ever need to use this again, but needed a way to check who last rebooted a server. We used this code: Get-EventLog -logname “system” | where-object {($_.eventid -eq 1074)} | % {if(($_.TimeGenerated).DayOfYear -eq (get-date).DayOfYear){$_.EventID,$_.TimeGenerated,$_.Message}} Note that event ID 1074 gives you if a user requested a… Continue reading