MS SQL Server Database Logging

In order to enable MSSQL Server database logging into the MSSQL Log 1). Open an elevated Poershell prompt 2). Run the query 1Invoke-Sqlcmd -Query "EXEC xp_instance_regwrite N’HKEY_LOCAL_MACHINE’, N’Software\Microsoft\MSSQLServer\MSSQLServer’, N’AuditLevel’, REG_DWORD, …

Get AD User Information

1PS C:\>get-aduser tor -Properties * Can also list all the servers on the domain 1PS C:\>Get-adcomputer -filter * -properties * | Select-object DNSHostName,whenCreated,Name,Created,Modified,LastLogonDate,Enabled,isDeleted | export-csv c:\servers.csv

wget with Powershell v2

1PS:> (new-object System.Net.WebClient).DownloadString("https://www.google.com") >> output.txt The URL should have http or https or web client will look for a file on disk. Powershell 3 and higher has other ways of …

Get System Downtime

Determine your Powershell exectuion policy 1Get-ExecutionPolicy Change your Powershell exectuion policy if restricted 1Set-ExecutionPolicy RemoteSigned Script to get system downtime 1234567891011121314151617181920212223242526272829303132333435363738[timespan]$downTime = New-TimeSpan -start 0 -end 0 [timespan]$totalDownTime = New-TimeSpan …