powershell

Tricks I wish I knew

18 Feb: PowerShell – Few tricks about HashTables and Arrays I wish I knew when I started

I’ve been working with PowerShell for a while now and like with most things I do I’ve learned it by doing and not by reading. I had a job to do, and since I don’t like doing things over and over, I thought it’s time to learn and do it in PowerShell. Problem with that approach is that you take bits and pieces from PowerShell scripts online that sometimes do the job but not necessarily pay attention to details. And it’s fine. I’ve learned a lot from reading someone else’s work, and I learn something new every day. Hopefully, it will be useful to you to some extent.
Server Types

06 Feb: How to find different server types in Active Directory with PowerShell

Working as a freelancer is a great thing if you can handle it. Each day, each week something new happens and a new problem shows up on my doorstep. It also means it’s almost never boring at your job and you get to play with new stuff. But there’s one drawback to this. You’re often thrown at the problem, told to fix it but often that’s about as much information as you get. It wasn’t very different today. I was told to switch Office 365 from ADFS to Password Synchronization. While reasons for this are not really important, the important question here is what is the name of AD Connect server that’s responsible for this configuration?
AccountLockout

24 Jan: Active Directory – How to track down why and where the user account was locked out

I’ve been working with Windows Events for a while now. One of the things I did to help me diagnose problems and reporting on Windows Events was to write PSEventViewer to help to parse the logs and write PSWinReporting to help monitor (with use of PSEventViewer) Domain Controllers for events that happen across the domain. It’s handy and I, get those excellent daily reports of what happened while I was gone.
Move-ADDirectoryServerOperationMasterRole

06 Jan: Active Directory – Move-AD Directory Server Operation Master Role: Access is denied

When working with Active Directory one of the common tasks is to move FSMO roles between servers. Well, maybe not that common but it happens from time to time where you have to move all or just some of the FSMO roles. For that purposes, there is single PowerShell command Move-ADDirectoryServerOperationalMasterRole. Sure you can do this via GUI but if there’s one command available to fix it all why bother? To make the move one has to be a Domain Admin, Enterprise Admin and Schema Admin. Everything was going smoothly for some roles but wasn’t working for others.
img_5c2cf9f7b3715

02 Jan: A command with name is already available on this system. This module may override the existing commands.

Another day, another issue one may say. Today I wanted to install one of my modules to a new server and was greeted with a well-known message (it may seem on first look): A command with name ” is already available on this system. This module ‘PSEventViewer’ may override the existing commands. If you still want to install this module ‘PSEventViewer’, use -AllowClobber parameter.
Format-Streams

18 Nov: PowerShell – Working with Format-Table in Verbose, Debug, Output Streams

As you may know, PowerShell has multiple streams. Write-Output, Write-Error, Write-Warning, Write-Verbose, Write-Debug, and Write-Information. It also has Write-Host which until PowerShell 5 was a bit special. Since PowerShell 5.1 it’s a wrapper over Write-Information, so it doesn’t kill puppies anymore. While I could spend the next five pages trying to give my best and describe those streams, there are already many articles describing them in detail. Please check the following link if you need that information.
PSSHaredGoods

16 Nov: PowerShell – Single PSM1 file versus multi-file modules

I’ve been working with PowerShell Modules for a while now, and most of my knowledge about them came from Warren F (psCookieMonster) blog about Building a PowerShell Module. It is a handy piece of information and recommended read for anyone starting up writing PowerShell Modules. He introduces an idea where a module is stored in multiple folders Private, Public, Bin, Lib and so on and having YourModule.psm1 as a wrapper for functions, binaries in those folders, where each function is stored in its file. It’s an excellent concept, and I use it every day. It allows me to jump into a file quickly I want to find and fundamentally easier for development, especially in teams.