[PowerShell] Check if file exists

The script below reads an input file from the command line and then checks if it exists. If not found it keeps prompting for a correct filename. FileToRead = Read-Host “Please enter the filename” $Found = “N” Do { if (Test-Path -LiteralPath...

[PowerShell] Check if AD Domain exists

This script checks if an Active Directory domain exists. If found it continues. If not it exits the script. $Domain = Read-Host “Please enter the domain name” try { Get-ADDomain -Identity $Domain | Out-Null Write-Host “[INFO] Domain found....

[PowerShell] How to deal with spaces in objects

Sometimes when you work with objects in Powershell and want to concatenate field as output you need to get rid of spaces. Below is an example on how to deal with that. The cmdlets below import records from the file C:\CSV-files\Userlist.txt, filters on Achternaam =...