Find and Unhide all Hidden Files Using PowerShell

This PowerShell one-liner will find all hidden files and folders in the current directory and turn off the Hidden attribute: Get-ChildItem -Force -Recurse | Where-Object{($_.Attributes.ToString().Split(“, “) -contains “Hidden”) -and ($_.Name -ne “thumbs.db”) -and ($_.Name -notlike “~*”) -and ($_.Name -ne “desktop.ini”) -and ($_.Name -ne “folder.ico”)} | foreach {$_.Attributes = “Archive”} I deliberately wrote this to skip thumbs.db, desktop.ini, folder.ico and Microsoft Office temporary files, because there […]

Read Me Leave comment

Use PowerShell to Get a List of Users on Windows 7

You can use PowerShell to get a list of local workstation user accounts on Windows 7 or Windows 10. (Probably Windows 8 and 8.1, but does anybody really care?) This is much easier on Windows 10, than on 7. Get-LocalUser | Select Name Not much to write about there, but most of us still have some Windows 7 computers floating around, and that won’t work […]

Read Me Leave comment

Add Blocked Senders to Exchange Online Using PowerShell

Many things in Exchange and Office 365 take too long to do via the admin console, but are too obscure to do routinely via PowerShell. Unless, that is, you have a script! This function will add a single sender address to your spam policy’s BlockedSenders attribute or a sender domain to the BlockedSenderDomains attribute. (If you find any errors in the code below, let me […]

Read Me Leave comment

Create Inbox Rules in PowerShell

Let’s say you want to create in Inbox Rule and you don’t want to (or can’t) use Outlook to do it. Who cares why, right? You just don’t. $ReasonsWhy = “Not Relevant” You can use the New-InboxRule to move, copy, delete, forward, classify…whatever…newly received messages, just like you can if you created the rule through Outlook’s wizard. You can’t do quite everything in PowerShell that can be done […]

Read Me Leave comment

Add a Prefix to Differentiate On-Prem from Cloud Exchange Cmdlets

If you use PowerShell to manage both on-prem and cloud Exchange resources, you can manage both in the same console by adding a prefix to the cmdlets of one or the other. It’s easier to add the prefix for Exchange Online cmdlets, so I’ll show you that. Simply copy and paste this code into the on-prem Exchange Management Shell to connect to Exchange Online and prefix the […]

Read Me Leave comment

Add and Remove Computers from Groups Using PowerShell

These two scripts will add and remove a domain-joined computer to and from, respectively, a domain group. It’s much quicker than typing out the whole cmdlet string each time you need it. Script One: Add a computer to a group. Usage: Add_ComputerToGroup <ComputerName> <GroupName> # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx # Filename : Add_ComputerToGroup.ps1 # Purpose : Adds a computer object to an Active Directory group. The group # […]

Read Me Leave comment

PowerShell to Add a Workstation to a User’s Log On To Property

It’s easy enough to use ADUC or ADAC to change the list of computers that a user account is authorized to logon to, but sometimes (like, whenever possible!) you need to use PowerShell. Let’s start by seeing what workstations the user is allowed to logon to now… PS C:\> Get-ADUser jay.test -Properties LogonWorkstations | Format-List Name, LogonWorkstations Name : Jay Test LogonWorkstations : testpc This tells […]

Read Me 3 Comments