PowerShell – Useful scripts

PowerShell – Useful scripts-

Here are some scripts which I used over the period of time just as a quick copy/paste to perform a few basic tasks.

  1. Installation of the application with silent parameters using PDQ Deploy. this will install Malwarebytes’ Anti-Malware very silent without any window and without a restart and will log the installation
mbam-setup-2.1.6.1022.exe /VERYSILENT /SUPPRESSMSGBOXES /NOCANCEL /NORESTART /SP- /LOG="%TEMP%\performancerestoration-1.1.log"
    • /SP- (disable the “This will install … Do you wish to continue” prompt)
    • /SUPPRESSMSGBOXES (only has an effect when combined with /SILENT or /VERYSILENT)
    • /LOG=”filename” (writes an installation log to a fixed path)
    • /NOCANCEL (prevents a user from canceling during the installation process)
    • /NORESTART (prevents setup from restarting the system after installation process)
    • /SILENT, /VERYSILENT (when the setup is very silent it won’t show any progress window)

2-  This script will remove a particular folder, sub-folder, and files under a particular target path.

$users = Get-ChildItem \\192.168.0.4\c$\Users\
foreach ($user in $users){
$folder = “$($user.fullname)\AppData\Roaming\extvisual”
If (Test-Path $folder) {
Remove-Item $folder -Recurse -Force -ErrorAction silentlycontinue
}}

This is work in progress and I will keep adding more scripts as I keep testing more scripts.