Server
Finding Services that are set to auto but are not running
Get-WmiObject win32_service | where {$_.state -eq "stopped" -and $_.startmode -eq "auto"}
Using PowerShell to do a WSUS cleanup
Invoke-WsusServerCleanup -CleanupObsoleteUpdates
Creating a file share and assigning share permissions
New-Item -Path c:\test -ItemType Directory New-SmbShare -Name Test -Path c:\test -ReadAccess Everyone -FullAccess User1 -Description "Test Share"
Creating a PowerShell Module
When you create a script module it needs to be in one of two places your profile path or "C:\Program Files\WindowsPowerShell\Modules"
After that you need to provide a folder and a file with the same name ending in .psm1
The following shows a quick way to make this on a server
This did not work on Windows 10 when I tested it due to built in protections
$moduleName = "NewTools" $path1 = Split-Path $profile $fullpath = $path1 + "\modules\" + $moduleName + "\" New-Item -Path $fullpath -ItemType Directory -Force New-Item -Path $fullpath -Name ($moduleName + ".psm1") -ItemType File -Force
Creating a profile
$profile is a built in variable that points to where your profile would be if it existed
The following script should make creating a profile faster
$path1 = Split-Path $profile New-Item -Path $path1 -ItemType Directory -Force notepad $profile
In notepad make some changes to your profile like CD \
and any other changes you want to make
Creating a Scheduled Task
Just like when you create a scheduled task using the GUI you need an action and a trigger then you need to register the scheduled task
Here is an example
$action = New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "C:\scripts\map-Pdrive.ps1" $trigger = New-ScheduledTaskTrigger -Daily -At 9am Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "MapPDrive" -Description "Map the P drive daily"