Windows

From Tuxmint Wiki
Jump to navigation Jump to search

Powershell

Search for last Logins via RDP

$startDate = (Get-Date).AddDays(-14).ToString('MM/dd/yyyy HH:mm:ss')
$endDate = (Get-Date).ToString('MM/dd/yyyy HH:mm:ss')
Get-WinEvent -FilterHashtable @{LogName='Microsoft-Windows-TerminalServices-RemoteConnectionManager/Operational';  
ID=1149; StartTime=$startDate; EndTime=$endDate} |
   Where-Object {
       $_.Properties[0].Value -ne $null -and
       $_.Properties[0].Value -notin @('IUSR', 'LOCAL SERVICE', 'DWM-1')
   } |
   Select-Object TimeCreated, @{Name='Username'; Expression={$_.Properties[0].Value}}, @{Name='IPAddress'; Expression={$_.Properties[2].Value}}

Get Printers from Printserver

Get-WmiObject -Class Win32_Printer -ComputerName PRINTSERVERNAME | Select-Object Name, DriverName, PortName, ShareName, Location, Comment, Default, Network, Published, Shared, Status

Active Directory

Check Password never expires checkbox for Service Account

Import-Module ActiveDirectory
$users = Get-ADUser -Filter {PasswordNeverExpires -eq $false -and SamAccountName -like "sa_*"}
foreach ($user in $users) {
   Write-Output "User $($user.SamAccountName) / $($user.Name) has the Password never expires checkbox NOT checked! Please fix it!"
}