2015/10/20

Montreal PowerShell User Group #02 - Using the Pipeline/Creating Script and Function



Join us for the Montreal PowerShell User Group #02 meeting on the Tuesday 27th of October 2015 from 6:00pm to 9:00pm at the Warner Brothers Games Studio!

We will have the two following presentations: Using the PowerShell Pipeline (Beginner level) and Creating Script/Function (Beginner/Intermediate level).

Both presentations will be presented by User Groups members: Martin Lebel and Gary Szabo. (Thank you guys!)

Hope to see you there! Free Pizza, Pop Corn and some games/movies to win!

Presentations


Using the Pipeline and formatting the output presented by Martin Lebel
Creating PowerShell Script and Function presented by Gary Szabo

When 


Tuesday, 27th of October 2015 from 6:00pm to 9:00pm

Where


Warner Brothers Games - 888 Maisonneuve Est - 6th Floor
Room: Jack Warner (In front of elevators)

2015/09/16

Montreal PowerShell User Group #01 - Material and pictures from my talk on Introduction to PowerShell


Here is the material from my presentation on Introduction to PowerShell at the first Montreal PowerShell User Group meeting that occurred yesterday (2015/09/15).

The Powerpoint presentation and PowerShell code is available on the meetup group page and Github:



Even thought I was a bit stress to present, I really loved the experience and I can't wait for the next meeting! We had a great group (17 people) who showed great interest and asked tons of questions!!


The next meeting will probably occur around the end of October.

2015/09/04

PowerShell/SCCM - Create a Dynamic Variable list during the task sequence

In my previous article I talked about SCCM Application and how to retrieve the applications targeted to a user.

Today I'll show how we can build a function to create a list of dynamic variables. This would be used in a Task Sequence during the Operating System Deployment in the task "Install Application".

First we will need to find the list of applications and then create a variable with a specific pattern for each of them.

What does it look like inside the task Sequence ?

Before we dig into the PowerShell, I think it is important to understand where everything will goes.

In the following task "Run PowerShell Shell Script", the script will retrieve in SCCM all the Applications advertised on the users (showed in previous article) and then create a bunch of variables that will be used in the task "Install Application".



2015/09/03

PowerShell/SCCM - Find Applications advertised to a user

The following function helps you retrieve all the deployment that a user is supposed to received.

We use this during the Operating System Deployment (OSD). Using the UDI we get the user account that will receive the workstation currently being deployed. This script allow us to retrieve in SCCM all the Application advertised on the user that needed to be deployed on the computer during the task sequence.

I know this could probably be done with the Configuration Manager module, but I'm pretty new with it and I was not sure it could be loaded in a task sequence, if you have the answer let me know in the comment section.

Here is the step by step how I found my solution. You can also go straight to the function at the end of this article.

Define Default Parameters

First I define a splatting to avoid repeating the same parameters in each command.
# Define default parameters (Splatting)
$Splatting = @{
    ComputerName = "Sccm01.lazywinadmin.com"
    NameSpace = "root\SMS\Site_FX1"
}

Retrieve a user in SCCM CMDB

Then I need to find a user in the SCCM Database to retrieve its ResourceID.
# Find the User in SCCM CMDB
$User = Get-WMIObject @Splatting -Query "Select * From SMS_R_User WHERE UserName='FxTest'"

Retrieve the collections the user is member of

# Find the collections where the user is member of
$Collections = Get-WmiObject -Class sms_fullcollectionmembership @splatting -Filter "ResourceID = '$($user.resourceid)'"

2015/08/31

Montreal PowerShell User Group #01 - Introduction to PowerShell



-English-

This is our first Montreal PowerShell User Group ! We'll start easy with a presentation on the basics of PowerShell ! Hope to see you there! Pizza, PopCorn and some free games to win!

When 

Tuesday, 15th of September 2015

Where

Warner Brothers Games - 888 Maisonneuve Est - 6th Floor
Room: Jack Warner (In front of elevators)


2015/08/30

PowerShell - Remove special characters from a string using Regular Expression (Regex)

Some more string manipulations! Today I'd like to remove the special characters and only keep alphanumeric characters using Regular Expression (Regex).

You might be interested to check a previous article where I showed how to remove diacritics (accents) from some strings, see here: http://www.lazywinadmin.com/2015/05/powershell-remove-diacritics-accents.html


My goal is to be able to keep only any characters considered as letters and any numbers.
If you are familiar with Regex, you could do something simple as using the metacharacter \w or [a-z] type of things. It's great when you only work with english language but does not work when you have accents or diacritics with Latin languages for example.

Preview of the final solution

2015/08/29

PowerShell/Office 365 - Get an Exchange Online user's distribution groups efficiently

In my previous post I showed how to retrieve the membership of one or multiple groups. In today's post I want to find the Distribution groups a user belongs to.

There are multiple approaches you could be using to gather this information but as an example I'll re-use the same one-liner from my previous article and simply filter with Where-Object to find a particular User.

This is probably the route PowerShell beginners would take and it is working 'Fine' in a small environment but not very efficient, you'll see in the following example.

In this environment, there are a bit more than 1800 Distribution Groups. I want to know which Distribution Group I'm member of.

Retrieving the count of Distribution Groups and an User account in Office 365


2015/08/24

PowerShell/Office 365 - Get the distribution groups membership

I was recently looking at Office365/Exchange Online to retrieve Distribution Group membership. This is pretty simple using something like:
Get-DistributionGroupMember -Identity "Marketing"

Not that prior to perforce the following command you need to be already connected to Office365, see this post.

Retrieving all members of each Distribution Group

Now if I want to retrieve all the Distribution group members, it's bit trickier you'll see. First I started by listing the groups members. My PowerShell instinct made me type Get-DistributionGroup|Get-DistributionGroupMember but it did not work, see below:



As the error message is stating that this Cmdlet does not accept input :-/

By using Get-Help on Get-DistributionGroupMember, we can check the parameters accepting Input:

(Get-Help Get-DistributionGroupMember).parameters.parameter|Select-Object name,parametervalue,pipelineinput