General
Last Friday I attended the first Dutch Powershell User Group meeting in Eindhoven at Master IT Training and it was great. There were a lot of knowledgeable and passionate people and the interactive sessions were great as well. Thanks go out to all attendees, but especially to the ones presenting and organizing the event.
The fact that we were asked to leave the building (because it was getting pretty late and they wanted to lock up), also stresses the passion of all attendees because. If this wasn’t the case we probably would’ve stayed a lot longer.
Be sure to check out the Dutch PowerShell User Group (DuPSUG) website and Twitter on a regular basis for articles and future events. Ed Wilson also wrote a post of the meeting on the “Hey, Scripting Guy! Blog”.
Photos
Sessions
Below are the sessions with some info about the speakers and their sessions. I also added notes I took and other information I looked up afterwards. If you come across any errors or have comments, please leave a reply so I can fix it.
- Using Windows PowerShell 3.0 to manage the remote Windows 8 workstation.
Ed Wilson (Microsoft Scripting Guy) | Slides and code | Blog | Twitter | LinkedIn- Community
- Powershell is all about the community and sharing. So even if your code is not that great, people might be able to use the concept or parts of it so share it.
- You can use the Technet Script Center or the Scripting Guys Script Repository. You’ll also probably get advice to improve your scripts and your skills.
- Don’t forget to swing by the Official Scripting Guys Scripting Forum as well.
- If you’re new to PowerShell take a look at the Scripting with PowerShell page.
- PowerShell remoting
- PowerShell remoting is great if you want to perform remote commands on servers and it’s also very easy to configure using a GPO.
- See these blog posts for more info about PowerShell remoting.
- CIM
- With the introduction of PowerShell v3 and Windows 8 and Windows Server 2012 CIM (Common Information Model) will become the new standard, replacing WMI. It’s very likely that Microsoft is heading towards CIM and investing less in WMI.
- CIM is an open industry standard and is used by non Microsoft devices and products as well. By example use it with network devices, storage devices and VMware.
- WMI uses Distributed COM, or more specifically RPC, which is not very firewall friendly. The new CIM cmdlets communicate over WS-MAN, using the WinRM service which is more firewall friendly. It’s also enabled by default in Windows 8 and Server 2012 (The CIM cmdlets will still use DCOM when you omit the
-computerName parameter to talk to the local machine). - Pre-Windows 8, pre-Server 2012 systems don’t support CIM. There is a nice blog post though about how you can target down level clients with the get-ciminstance cmdlet though.
- The syntax for CIM and WMI cmdlets is very similar.
- You can define multiple CIMgroups and use them as targets where appropriate.
- When you use get-wmiobject with the -credentials $cred you would get an error when you execute it on a local machine. This is not the case with CIM cmdlets.
- CIM and WMI cmdlets aren’t 100% identical in performance. Each has advantages in specific scenarios.
- Not all commands can be used in a CIM session. Use the following command to see what commands are CIM session compatible:
get-command -parametername cimsession - Use CIM to get info from multiple systems:
$credential = get-credential
$CN = get-adcomputer
$CIM = New-CimSession -Credential $credential -computername $CN.name
$CIM
Get-CimInstance -CimSession $CIM -ClassName WIN32_operatingsystem - Check Richard Siddaway’s blog for posts regarding CIM.
- Introduction to CIM cmdlets
- Other stuff
- When using some commands, you will get a pop-up requesting confirmation. You can prevent this by using -confirm:$false
get-netadapter | enable-netadapater -confirm:$false - Use compare-object to compare by example the installed hotfixes or running services on different machines.
- When using some commands, you will get a pop-up requesting confirmation. You can prevent this by using -confirm:$false
- Community
- Protect your PowerShell scripts with version control
Stefan Stranger | Slides and code | Blog | Twitter | LinkedIn- There are many products that can be used for version control. These include, but are not limited to: Team Foundation Server 2012 (TFS), Mercurial, git, Apache Subversion (SVN), CodePlex. Determine what best fits your needs.
- Team Foundation Service is an online version of Team Foundation Server. Up to 5 users are free. For a limited time all use is free as well.
- When using products, keep in mind that there might be limitations. A common heard limitation is the path length limit of 255 characters.
- Stefan showed a teaser of his upcoming TFS ISE Add-On. This allows you to interact with Team Foundation Server directly from within the PowerShell Integrated Scripting Environment (ISE). Follow him to keep track of its progress.
- To create your own add-on, you can use module show-ui, ISE Extensions, icicle, module ISEpackv2
- From command, to script, to function, to advanced function, to tool.
Jeff Wouters | Slides and code | Blog | Twitter | LinkedIn- Handy (beginners) stuff:
- List properties and methods of a command or object using get-member
- Use get-help <cmdlet> -detailed, get-help <cmdlet> -examples, get-help <cmdlet>-full to get more information about cmdlets.
- Open help about cmdlet in seperate window : get-help <cmdlet> -showwindow
- Easily filter and copy results using: <cmdlet> | out-gridview
- To show only the value of a PowerShell result (and not the column header) use Expandproperty. By example:
Get-Childitem $env:systemroot | select -ExpandProperty Name - Test the performance of your code using measure-command. Different approaches can make a huge difference. A good example when using VMware PowerCLI can be found here. Another example is the difference when using get-content, .net or com objects.
- Use a GUI interface to guide you through proper use of cmdlets: show-command <cmdlet> Beware: Pressing the Run button will run the code. In most cases you would want to use the copy button.
- When you want to see what information you can extract using a specific cmdlet, you can use : <cmdlet> | select * or <cmdlet> | fc
- To get specific information that is not available using select *, you can use a more specific command like by example:
get-childitem $env:systemroot\system32\mspaint.exe | select -expandproperty versioninfo | select * - A quick and dirty way to prevent you from seeing output/errors is | out-null
- Use start-transcript and stop-transcript to log your commands and the output. When you’re using the ISE, you should read this post to be able to use transcripts.
- Consider what is the best approach for your situation. Add all results to an array and filter afterwards or only add filtered results to an array and work with that. By example when you use $array = get-process , $array will contain the complete process objects with all its values and you can simply (re)use the already collected data without having to query the processes everytime. When you use $array = (get-process).name , $array will only contain the name values for all processes. If you would want to get by example the ID, you would have to run another query.
- If you have a desire for checking for write locks on files, read this.
- Functions:
- To get to know more about functions : get-help about_functions
- Use ISE snippets (CTRL+J) to get good starting templates to use when creating your own functions, workflows, etc.
- When creating functions, use begin, process and end.
- Workflows:
- Handy (beginners) stuff:
- Splatting in PowerShell and [adsisearcher].
Jaap Brasser | Slides and code | Blog | Twitter | LinkedIn- Code samples
- Check these downloadable code samples of Jaap’s session
- Beware: stored credentials can easily be retrieved using $cred.GetNetworkCredential() | FL *
- Splatting
- Splatting is basically storing parameters in a hash table. It is a method used to make PowerShell code neater, more orderly and better readable.
- Backticks ( ` ) are often used for breaking lines in powershell but is risky. By using splatting you mitigate these risks.
- Splatting can be used to manipulate the output format as well.
- Splatting is very appropriate to use when creating active directory (AD) users because many parameters need to be specified.Keep in mind that you need to use a secure string to be able to create AD users.
- ADSISEARCHER
- Even though there are active directory cmdlets available, there are reasons to use adsiseacher instead. By example for using the active directory cmdlets you need more permissions which not all users might have like by example an Exchange admin. Also the queries you define are LDAP queries which can be used in other LDAP compliant products as well.
- Beware: ADSISEARCHER results return an array, not a string or an integer. So to extract data, treat it as such. By example to get the first result, use [0].
- AD uses filetime (LDAP compliance).
- Code samples
Unfortunately due to technical difficulties we were not able to establish a live meeting to the UK. This meant the session PowerShell and WMI by Richard Siddaway could not take place.
Richard Siddaway | Blog | Twitter | LinkedIn
3 responses to “Summary of 1st Dutch PowerShell User Group (DuPSUG) meeting”