Profile scripts work like autostart scripts in PowerShell. They do not need to exist, but if they do, PowerShell executes its content silently during each launch. There are up to four profile scripts, and this line exposes their paths:
PS> $profile | Select-Object -Property *
Be careful when using $env:userprofile or $home to create paths to user files. When a Windows box is set up for OneDrive, the documents folder may have been redirected to a subfolder named “OneDrive”. Here are some examples:
The Get-EventLog cmdlet provides easy access to event log entries in the primary Windows event logs, however it neither can access the many application level event logs, nor is it available at all in PowerShell 7.
If you ever plan to run your code in PowerShell 7, you should start getting used to its…
PowerShell remoting maintains a list of trusted IP addresses and/or machine names on the client side (the machine that issues the command and authenticates at the server). This list is important for you because it governs how you can authenticate to remote computers.
By default, PowerShell supports Kerberos…
The PowerShell ISE built into Windows works with Windows PowerShell only and is stuck at PowerShell version 5.1. Typically, when you want to use an editor to write PowerShell 7 code, Visual Studio Code and the PowerShell extension is the way to go.
Still, you can make PowerShell ISE “talk” to PowerShell…
In PowerShell 7, there is a new set of variables all starting with “Is”. They help you understand the environment in which your script runs:
PS> Get-Variable -Name is*
You can use PowerShell to enable and disable real-time antivirus protection provided you are running with full Administrator privileges. Temporarily disabling real-time antivirus protection may occasionally be helpful when there is explicit need to run legit scripts that may otherwise be blocked. Generally…
In the previous tip you learned how you can query WMI to find out the antivirus product present on your Windows machine:
$info = Get-CimInstance -Namespace root/SecurityCenter2 -ClassName AntiVirusProduct
The ProductState property encodes additional pieces of information, telling you whether…
A PowerShell one-liner can help you identify the antivirus product installed on a Windows box:
PS> Get-CimInstance -Namespace root/SecurityCenter2 -ClassName AntiVirusProduct
Add the -ComputerName parameter to query remote systems.
Note that this line returns only antivirus products that properly…
If you use Microsoft Teams for video conferencing, you may occasionally want to clean cache files and remove traces which reside in a number of subfolders.
You can adjust the code from our previous example to do the cleanup for you:
# the folder that contains the Microsoft Teams data
Powered by IDERA