Tag powershell

How to Use PipelineVariable

Put your hands up, have you ever bumped into the -PipelineVariable parameter in PowerShell cmdlets and wondered what it stood for? I have. But you use tab-completion when you are feeling lazy or want to get something done in a blink. Both these situations are not conductive to experimentation. What is a pipeline Think of cmdlets as little machine parts. Each takes an input, processes it and gives an output. You start with something raw, place it in the first machine, which processes it and gives you the output.

How to Add or Remove Users from Active Directory Groups

Active Directory has been one of my favourite tools in which I could automate repetitive processes. Starting from user additions to user deletions, clean-up, audits, all the way to new hire and user account termination process. Active Directory is a fantastic avenue for automation. And, who does not like hyper-efficient Active Directory administrators? I thought I would start a series on Active Directory automations. Today, we look at adding users to and removing users from Active Directory groups.

On code optimisation

As organisations move towards more automation, those that use Windows-based environments encourage learning PowerShell. Our organisation is one of these. This morning, we received a challenge: Before you leave for the holidays, the Elves in Accounting just need you to fix your expense report (your puzzle input); apparently, something isn’t quite adding up. Specifically, they need you to find the two entries that sum to 2020 and then multiply those two numbers together.

Updating a distribution list with error handling

This morning I woke up to a query whether we could do a bulk addition of users (with email addresses) to a distribution list. The team got a list of users to add and the name of the distribution group as part of the request. The administrators would then copy-paste the email column to a new CSV file, place the file on the desktop and run a one-liner. Import-Csv "C:\Users\USER88398\Desktop\book1.csv" | ForEach-Object { Add-DistributionGroupMember "DL-DistributionGroup070818" -Member $_.

How to run a PowerShell script

Often, administrators face situations where they run scripts written by someone else. After all, that is what a community is all about. When the admin is new to PowerShell, and when he does not understand how to run a PowerShell script, he feels a little lost. And this is normal. I often meet administrators who are unsure how to run a script. How to run the function within the script Calling functions outside of the script Other methods of loading functions Calling a function without loading it into the session Loading the function into the session Summary Now, sometimes, the approach I used to take was to write the script in such a way that the moment someone calls it either from the console or using one of the integrated environments, the script would run and complete its task.