Creating classes in C# for PowerShell use

Sometimes it is just easier to write compiled code! This is a small example of how to create a custom object in C#and then use it. C# Code Sample using System.Text; public class Beer { public string Name; public string Type; public Beer(string NameIn, string TypeIn) { this.Name = NameIn; this.Type = TypeIn; } } Create a folder with the same name as the dll that gets compiled and place the newly created dll in this folder. Read more →

PowerShell v5 has class!

PowerShell version 5.0 added the ability to use the class designator in scripts. Don Jones has a good write up on it. This allows for live .NET framework class creation. This is a REALLY nice feature. There were a few ways to create custom objects in PowerShell before this, including specifying c# code directly in the script, using add-member and other ways. These all worked fine, but each has rather annoying limitations or overhead. Read more →

Remotely managing a WDS server with PowerShell or WDSUTIL

If you try to run any of the CmdLets in the WDS PowerShell cmdlets remotely via Invoke-Command, Enter-PSSession, CIMSession, or even PSEXEC it will fail with the error: _The operation being requested was not performed because the user has not been authenticated. If this is happening to you, you are screwed. Kind of. Remotely managing an AD Integrated WDS is simply impossible as far as I can tell. To fix this is you have to remove the WDS role and then add it again. Read more →

My Home Lab

A prerequisite read to this is here. Don Jones is a genius. Enough said. And a special shout out to @MeghNeupane for the initial hardware recommendation. Recently I transitioned professionally from internal IT to external customer facing IT. This is a much more fast paced and cutting edge field to be in and as such I determined it was time to take my home lab setup much more seriously. I simply needed a place to work on things on a whim that were not constrained in any such way. Read more →

ConfigMgr – Add OS Requirements to an application deployment type

This was updated again 6/1/2017. Changes were needed in order to avoid corruption. Mainly, a new GUID needed to be generated and used in order to ensure the changes were recognized. Hat tip to Jeff Scripter for figuring this out. Thank you. This was updated 6/21/2016. The script was over hauled to handle windows 10, multiple deployment types and more. The script and supported files can be found on github here. Read more →

Modifying App-V Pass through Filters (reg_sz mult)

In PowerShell v5.0 passthrough filters were implemented that prevent certain registry keys and values to be part of the virtual package. Good article here. One of these is the HKLM\Software\Policies key. This essentially prevents a virtual package from overriding GPO settings. That’s normally awesome, but what if I really wanted some policy settings in my package as opposed to on the workstation itself? This is possible. Below is an example of how to modify a multi value registry string. Read more →

Disable Offline File Sync

Offline file sync can be shut off via the UI in the control panel, but upon inspection using procmon it doesn’t actually appear to shut it off entirely. There are still write happening to c:\windows\csc everytime a network resource is accessed. [c:\windows\csc\v2.0.6] I am not sure this caused much of a degredation for the end user experience in general, but with one particular home grown and very legacy application this caused significant performance problems (400-500% slower). Read more →

PowerShell – WMI TPM and Encryption Status

This is a example of how to query the status of the TPM chip and Bitlocker Encryption status of a volume. The C: drive in this case. Notice the namespaces, that’s the trick here. Otherwise, simple stuff. $ComputerName = 'HOSTNAMEHERE' #TPM Status Get-WMIObject -Namespace "root/CIMV2/Security/MicrosoftTpm" -query "SELECT * FROM Win32_TPM" -ComputerName $ComputerName #Volume Status (C drive) Get-WMIObject -Namespace "root/CIMV2/Security/MicrosoftVolumeEncryption" -query "SELECT * FROM Win32_EncryptableVolume WHERE DriveLetter='C:'" -ComputerName $ComputerName Read more →

Using Select-String to search ConfigMgr log files

Have you ever tried to track down why a deployed Application isn’t doing what you expected? So you start looking at all the various logs that may be appropriate while hunting for clues? I have found Select-String to be quite helpful at times as a starting point when gathering clues. In this case, I will search for an application CI Unique ID. You can just as easily do this by application name, deployment type name, CI name, Distribution Point, etc, etc. Read more →

Get SharePoint list items using Get-WebService

This is an example of how to get SharePoint list items using Get-WebService. This does not require any SharePoint modules or special dlls to be loaded. This particular example shows how to get back a particular set of items. You pass in a Query Column and Query Value and a CAML query is created. i.e. QueryColumn = Title and QueryValue = Item1. All matching items are returned. This is a simple example, you can get way more precise if needed. Read more →