Enable Powershell

powershell \"set-executionpolicy bypass -force\"
powershell \"Enable-PSremoting -Force\"


Enable RemoteSigned scripts

Set-ExecutionPolicy RemoteSigned

Or regedit to HKLM\\\\SOFTWARE\\\\Microsoft\\\\PowerShell\\\\1\\\\ShellIds\\\\Microsoft.PowerShell, create ExecutionPolicy as REG_SZ with RemoteSigned.

Homemade script without signature

Set-ExecutionPolicy Unrestricted


ForEach ($user in $users) {


Console output

Write-Host --NoNewLine

Specific level output (Debug, Information, Warning, ...)

Write-Information ($user.GivenName + " " + $user.Surname + " = " + $user.UserPrincipalName + " = " + $DC2eMail)

For those levels to be printed, each one need an environment variable to be set. And set as silently not to be printed. And there are other options, -Stop, -Suspend

$DebugPreference = "Continue"
$DebugPreference = "SilentlyContinue"

CSV Output

New-Object -TypeName PSCustomObject -Property @{
       Email1 = $user.UserPrincipalName
       Email2 = $DC2eMail 
   } | Export-Csv -Append -NoTypeInformation -Path $OutputFilePath -Delimiter ';'

More about an object

Getting all user field

Get-ADUser -Filter *| Get-Member

Uninstall software

Here's how to list all installed software

If(!([Diagnostics.Process]::GetCurrentProcess(). Path -match '\\syswow64\\')) {
  $uninstallPath = "\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
  $uninstallWow6432Path = "\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"
    if (Test-Path "HKLM:$uninstallWow6432Path" ) { Get-ChildItem "HKLM:$uninstallWow6432Path"} 
    if (Test-Path "HKLM:$uninstallPath" ) { Get-ChildItem "HKLM:$uninstallPath" } 
    if (Test-Path "HKCU:$uninstallWow6432Path") { Get-ChildItem "HKCU:$uninstallWow6432Path"} 
    if (Test-Path "HKCU:$uninstallPath" ) { Get-ChildItem "HKCU:$uninstallPath" } 
  ) | ForEach-Object { Get-ItemProperty $_.PSPath } | Where-Object { $_.DisplayName -and !$_.SystemComponent -and !$_.ReleaseType -and !$_.ParentKeyName -and ($_.UninstallString -or $_.NoRemove) } | Sort-Object DisplayName | Select-Object DisplayName
} else {
  Write-Host -ForegroundColor Red "You are running 32-bit Powershell on 64-bit system. Please run 64-bit Powershell instead."

To search for a specific software, filter this list etc, update the Where-Object with something like Where-Object { $_.DisplayName -like "cloud" }

Win32_Product kind can be remove adding | ForEach-Object { $_.Uninstall()}

Get-WmiObject -Class Win32_Product -Filter "Name like '%Microsoft System Center Virtual Machine Manager DHCP Server (x64)%'" | ForEach-Object { $_.Uninstall()}