Showing posts with label ps1. Show all posts
Showing posts with label ps1. Show all posts

Wednesday, September 16, 2020

Disable Windows Defender Real-time protection from the command line

Why? Because it significantly slows down Visual Studio build process.

PowerShell

Get the current status:

(Get-MpPreference).DisableRealtimeMonitoring

Disable Real-time protection (requires admin rights):

Set-MpPreference -DisableRealtimeMonitoring $true

Command line

Get the current status:

powershell (Get-MpPreference).DisableRealtimeMonitoring

Disable Real-time protection (requires admin rights):

powershell Set-MpPreference -DisableRealtimeMonitoring $true

Tuesday, September 13, 2016

Export all third-party drivers from a Windows image to a destination folder


Export-WindowsDriver -Online -Destination E:\DriverBackup

Thursday, June 2, 2016

How to create a RAM disk at system startup using ImDisk


$taskname = "Create RAM disk at startup"

$credential = $Host.UI.PromptForCredential($taskname, "Enter user account information for running this task.", `
    "$env:USERDOMAIN\$env:USERNAME", $env:userdomain)
$username = $credential.UserName
$password = $credential.GetNetworkCredential().Password

$action = New-ScheduledTaskAction -Execute imdisk -Argument '-a -s 1G -m R: -p "/fs:ntfs /v:RAMDISK /q /y"'
$trigger = New-ScheduledTaskTrigger -AtStartup
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName $taskname -RunLevel Highest `
    -User $username -Password $password

Friday, December 6, 2013

Pause PowerShell script until key press

These 2 lines pause a PS1 script until the user presses a key. Fully mimics Windows/DOS pause command.

Write-Host -NoNewline "Press any key to continue . . . "
$host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")