Simplify Your Scripting Life By Creating PowerShell ISE snippets

Leave a commentPowerShell

This post is dedicated to the forgetful. I have learned to cope with my forgetfulness by creating PowerShell ISE snippets.

I’ll be the first to admit that I tend to forget things. All the time. So much, in fact, that it may even seem intentional.

Does this sound familiar? Have you ever…

  • Opened up old scripts in order to remember exactly how you used a particular cmdlet?
  • Saved script templates so that you’d have an example of a particular cmdlet or syntax?
  • Ripped out your hair in frustration because you can’t find those old files or templates?!

Awesome. You’re human. We’ve all done that. Especially us forgetful folks.

Now, wouldn’t it be fabulous if there was a much simpler way to save your awesome syntax *and* your hair?

Well, you’ve come to the right place!

PowerShell ISE Snippets

When a problem comes along, yoooouuu must snippet.    ~ Devo. Maybe.

The PowerShell ISE has a slick little feature called snippets that you may or may not be familiar with! They were introduced way back in version 3 of the ISE.

You may already be using this feature without realizing it. Have you ever pressed Ctrl+J while using the ISE? Maybe you’ve right-clicked and opened up the context menu and selected Start Snippets. Both of these pop up the available snippets!

Go on! Try it out! All you need to do is select a snippet from what’s available.

At this point, you may be thinking, “That’s pretty nifty, but what good does that do me?”.

Lots of good, I say. Lots!

You will find that there are many default snippets that are available for you to use right out of the box. How thoughtful of the PowerShell team!

  • Need a Do While snippet? Done.
  • Need a Try/Catch snippet? Piece of Cake.
  • Need DSC template snippets? Fuhgeddaboudit!

Now, this is all fine and dandy, but what happens when you want something that’s simply not available? 

You pick up your mighty PowerShell hammer and create it!

 

New-IseSnippet

Brace yourself. You’re going to love this. There is a cmdlet made specifically for creating PowerShell ISE snippets. *gasp!*

It’s called New-IseSnippet and it is wonderfully wonderful.

New-IseSnippet only has a few parameters, so it is really easy to get a new snippet created. Here is a list of those parameters.

-Title string (required)
This is what shows up in the snippets popup. It’s also the name of the snippet file.

-Description string (required)
This is what shows up in the description section of the snippets popup.

-Text string (required)
This is the PowerShell code that is actually added to your editor.

-Author string
This shows up in the snippet file itself rather than within the editor.

-CaretOffset Int32
This is the character offset for the position of the cursor after adding the snippet to your editor.

Here is where some of the parameters will show up within the snippet.

Now, enough with the talk. Less talk and more typing!

 

Creating PowerShell ISE Snippets with New-IseSnippet

Hands down, the hardest part of this entire process is coming up with a snippet that you want to create.

To start, let’s keep it simple and find something that you often use in your code. I often find myself using Test-Path in an If statement, so here’s an example snippet that I might create:

$Title       = "If Test-Path"
$Description = "If Test-Path valid do something. Or Do something else. You decide."
$Author      = "Kris"
$Text        = @'

If (Test-Path $SomePath) {

    # If Path valid

} Else {

    # If Path not valid

}
'@

New-IseSnippet -Title $Title -Description $Description -Author $Author -Text $Text

 

Give that a spin. When you open up the snippets popup menu, you’ll see “If Test-Path” is an available snippet to use.

Now, when you select it, you should magically see If Test-Path appear.

Easy peasy. You’ve got this down. You’re pretty much a pro at this now.

So, let’s add another luscious layer to this delectable cake.

 

Creating PowerShell ISE Snippets with a PowerShell ISE Snippet

While on the subject of PowerShell ISE snippets, I decided to create a snippet that creates snippets, a little “snipception” if you will. Deep, I know.

Mostly, I wanted to give an example of using the -CaretOffset parameter and thought that this would be a fun example.

$Title       = "Snippet Template"
$Description = "'When a problem comes along, yooouu must snippet...' ~Devo. Maybe."
$Author      = "Mr. Snippet"

$Text = @'

$Title        = ""
 $Description = ""
 $Author      = ""
 $Text        = @"

"@

New-IseSnippet -Title $Title -Description $Description -Author $Author -Text $Text
'@

New-IseSnippet -Title $Title -Description $Description -Author $Author -Text $Text -CaretOffset 16 -Force

 

This will create a snippet called Snippet Template that you can use for creating even more snippets!

The -CaretOffset 16 part means that the cursor will start after the 16th character when the snippet is used.

 

Wrapping up

Well, that’s basically it. As you saw, it is fantastically fabulous. So, if you use the ISE, you should take a look at creating your own custom snippets. 

#Snippets4Ever #PowerShellLife or, however kids these days portray their excitement over snippets and PowerShell.

Happy PowerShelling!

 

Bonus

Just in case you were wondering (and I’m sure you were), your newly created snippets will be stored in your user profile directory:

$Env:USERPROFILE\Documents\WindowsPowerShell\Snippets

These are saved as XML files (.ps1xml files). That means that you can use all the powers of XML manipulation to create, modify, save, backup, and even cherish those files. Hurray!

Uninstall Skype for Business with OCT or Click-to-Run

Leave a commentUncategorized

The Powers From On-High have declared that no more shall Skype for Business be installed in your organization. No more recipe sharing, pictures of Ms. Coddlebottom’s trip to Aunt Bethany and Uncle Cleatus’ gator farm, or HR infractions in the form of wildly inappropriate memes involving kitchen utensils and spray foam. You have been tasked, and you will prevail.

Depending on which of the two methods you used to install Skype for Business, there are three methods of expungement. The first uses the Office Customization Tool (OCT), the second uses PDQ Inventory to (help) remove the Office Deployment Tool (Click-to-Run or C2R), and the third uses an XML to remove the C2R version.

If my math is right, that’s one for the OCT and two for the C2R.

Here we go.

Method the First: Office Customization Tool (OCT)

Uninstalling Skype for Business as a feature of Office 2016 is relatively straightforward. With the exception of the MSP, uninstalling follows the same steps as installing Skype for Business.

  1. To remove Skype for Business after an Office 2016 (OCT) installation, create another MSP using the same parameters as the install, except for the Set feature installation states. Change the features as seen below:
    how to uninstall skype for business
  2. Save the MSP. In this example, the MSP is saved with the highly creative name of SkypeUninstall.MSP.
  3. Create a package in PDQ Deploy. Add a PowerShell step. You will need to kill the process first or the uninstall will fail with a 17002 error or something else that will not be at all helpful:
    Get-Process "Lync*" | Stop-Process -Force
    
  4. Add an Install Step. Select the MSP file in the Install File field using the File Picker […]. The necessary parameters are added for you automatically because we are wizardly beings of deployments. For more information on how to create the package with Conditions and Options, please see the Deploy Office 2016 KB.
  5. Save the package and deploy (right-click the finished package and click Deploy Once) to computers with Office 2016 and the Skype for Business feature installed. As always, it is recommended to test the package first.

Method the Second: C2R Using PDQ Inventory

We’re going to do this quickly.

  1. In PDQ Inventory, double-click a computer in a collection that has Skype for Business (C2R) installed.
  2. Click on the Applications page in the Computer Window and navigate to the entry for Skype for Business. The Uninstall column contains the uninstall string for Skype for Business 2016:
    
    "C:\Program Files\Common Files\Microsoft Shared\ClickToRun\OfficeClickToRun.exe" scenario=install scenariosubtype=ARP sourcetype=None productstoremove=SkypeforBusinessRetail.16_en-us_x-none culture=en-us version.16=16.0

    The uninstall string above can be used to create a package in PDQ Deploy to uninstall Skype for Business. Exclude the last two statements, culture=en-us version.16=16.0.

  3. Create a new package in PDQ Deploy, name it something meaningful.
  4. Add a Command Step and include the following in the Command window, which has the culture=en-us version.16=16.0 removed (for Free users, you can create a .bat file and deploy that using an Install Step, but Enterprise = More Magic).
    "C:\Program Files\Common Files\Microsoft Shared\ClickToRun\OfficeClickToRun.exe" scenario=install scenariosubtype=ARP sourcetype=None productstoremove=SkypeforBusinessRetail.16_en-us_x-none
  5. Save the package and deploy (right-click the finished package and click Deploy Once) to computers with Skype for Business Click-to-Run installed. As usual, we recommend you test this first.

Method the Third: C2R Using an XML

Follow this handy walkthrough:

  1. If you haven’t done so already, download the Office 2016 Deployment Tool (for C2R deployments) from Microsoft’s site: https://www.microsoft.com/en-us/download/details.aspx?id=49117
  2. Create the necessary shared directory to serve the C2R/Skype for Business “deployment”: \\server\share\
  3. Install the Office 2016 Deployment Tool for Click-to-Run, choose the extraction location to the previously created \\server\share\
  4. Copy the configuration.xml (created with the deployment tool) to SkypeRemove.xml or another name of your choosing, in the same directory.
  5. Edit SkypeRemove.xml. Your XML should look something quite close to this (change the Language ID and Product ID as appropriate):
    <Configuration> 
      <Remove>
       <Product ID="SkypeforBusinessRetail" >
        <Language ID="en-us" />
       </Product>
      </Remove>
     <Display Level="None" />
     </Configuration>
  6. In PDQ Deploy, create a new package and name it something meaningful.
  7. Add a Command step (Click New Step > Command or Steps and select Command), modify to match your \\server\share choices from above:
    "\\server\share\setup.exe" /configure "\\server\share\SkypeRemove.xml"
    

    Set the deployment Run As option to Deploy User (Interactive)

  8. Save the package and deploy (right-click the finished package and click Deploy Once). Once you’ve determined Skype for Business has been removed successfully, deploy at will.

Notes and Addenda of Some Import:

Troubleshooting:

  • Error 17002. This error occurs if the Lync.exe process is still running when an uninstall is attempted, specifically the Skype for Business feature (OCT) uninstall.
  • Make certain you are uninstalling the appropriate product as expressed by the Product ID defined by Microsoft. Skype for Business has two Office 2016 options: SkypeforBusinessRetail and SkypeforBusinessEntryRetail.

See Also…
Words:
Deploy Office 2016 Using The Microsoft Office Customization Tool
Deploy Office 365
Videos:
Silently Installing Office 365
Admin Arsenal Live! : Uninstalling Microsoft Office with PDQ Deploy
Admin Arsenal Live! : Adding and Removing Microsoft Office Components
Configuring and Deploying the Microsoft Office Customization Toolkit
Preparing The Office Customization Toolkit For Deployment
Deploy the Office Customization Toolkit Remotely>
Microsoft:
Product IDs that are supported by the Office Deployment Tool for Click-to-Run
Office 2016 Deployment Tool
Office 2013 Deployment Tool
Language Identifiers

Enforcing Execution of Browser Extensions Explicitly – Part II

Leave a commentUncategorized

Part the Second: Internet Explorer

A few weeks ago, we posted about how to manage Chrome Extensions. This week, we’re doing the same for Internet Explorer (IE), the other enterprise browser. And like Chrome, we’re using the best tool for the job, Group Policy. (See the note at the end of this blog for information about IE’s future).

Let’s get to it.

Add-on Management for Internet Explorer:

The first thing you want to do is set up Internet Explorer the way you want it set for your users. This means all the add-ons they could possibly need should be included. You can add some of the pre-built add-ons from the IE Gallery. You’ll notice, however, the Gallery is a lot smaller than it used to be and certain things no longer work. 404 Page Cannot Be Displayed. Sad! Other add-ons can be included by deploying programs with IE add-ons included (e.g. Adobe Reader, Adobe Acrobat, Office, Java, etc.)

Once you’ve selected all the add-ons, go to manage add-ons in IE, right-click one of the add-ons and select More Information. You’re going to need the Class ID for the GPO. Copy the More Information into Notepad or other text editor so you can copy the Class ID.

Repeat this process for all the add-ons you want to manage in IE.

Now create the GPO.

Internet Explorer Add-on management should already be included in Group Policy. Open the GPMC, create a new Group Policy, edit that policy and navigate to Computer Configuration > Policies > Administrative Templates > Windows Components > Internet Explorer > Security Features > Add-on Management. You should see something like this:

We’re going to set up the Add-on List. Open that setting, enable it, and click Show… next to Add-on List. Add your Class IDs you retrieved earlier and choose the value you want. The values are as follows:

0 = The add-on is disabled and cannot be changed

1 = The add-on is enabled and cannot be changed.

2 = The add-on is enabled and can be changed.

Here’s an example of the add-ons with values for the Add-on List setting:

The next thing is to deny all the add-ons not defined in the Add-on List. It’s pretty straightforward. Open the Deny all add-ons unless specifically allowed in the Add-on List and enable the setting.

That’s it. Save the GPO, apply it wherever makes sense, and you’re finished.

Next, let’s run some tests.

First, we deploy the Shockwave Player and Java to a machine with IE installed. We see some add-ons in the Manage Add-ons properties of IE.

Next, we wait or run gpupdate on the target machine, restart IE. Go to Manage Add-ons again, and voila:

Next, we’ll take a look at Bethany Coddlebottom’s machine (the GPO has not been applied)…

Move that machine into range of the GPO, run gpupdate, and restart IE:

That’s it.


NOTES:

As you likely know, on January 12, 2016, support for older IE versions ended. Security updates would still be provided for the latest supported version through the OS lifecycle, but no additional IE releases were planned. You can read more here.

Introducing PDQ Deploy Throwback

Leave a commentUncategorized

Right now you can head to your local store and pick up a six-pack of Crystal Pepsi. Turn on Netflix to see reboots of X-Files, and Full House, and coming soon to a theater near you: Power Rangers, and Baywatch… respectively. Although it doesn’t take much to imagine a crossover between the two: “Mighty Morphin’ Power Baywatchers”… The 90’s are back baby! Why am I bringing this up? Well we’re jumping on this pre-millennium bandwagon like the sellouts we strive to be.

Introducing

PDQ Deploy distributed on thirty (30) 3.5″ floppy disks for your install pleasure (or suffering, whatever you’re into)

Tech is going retro, and so should you. Order your set of floppies, and we’ll have them sent 90’s style… by carrier pigeon! That’s right, the dream of the 1890s is alive at PDQ.com.

Some Restrictions Apply, not available in all States, Territories, or Colonies. Void where prohibited or construed as embarrassing. Please allow 4 to 6 years for delivery.

Look how they stack!

 

Happy April Fools' Eve PDQers!

Adding and Removing Windows 10 Apps with PowerShell

Leave a commentPowerShell, Uncategorized

Raise your hand if you’ve ever had problems removing Windows 10 Apps. Raise your other hand if you’re fancy enough to know these by their name, Universal Windows Platform apps.

If you’ve got both hands up, clap them together. You’re fancy!

Generally speaking, removing Windows 10 Apps with PowerShell can be tricky. Once you get the hang of it, however, you may find it surprisingly straightforward.

In contrast to the fire hose blast of info in our webcast about Windows 10 Apps and Advertising (link here), I’m going to keep this blog relatively simple and code-focused.

Before we begin, there are some important things to note:

  • Remove-AppxPackage only removes apps for the current user
  • Remove-AppxProvisionedPackage doesn’t uninstall the app, it removes the provisioned package from Windows
  • Removing provisioned packages prevents new users from receving a Windows App
  • All glory to the hypnotoad

Also, there is no time for raised hands, so put your hands down and let’s get typing!

Removing Windows 10 Apps

You have before you the PowerShell gold that is removing Windows 10 apps. These commands will help with removing Windows 10 apps in a very simple and straightforward way.

Get installed Windows 10 Apps
Get-AppxPackage

 

Get Installed Windows 10 Apps by Name
Get-AppxPackage *weather*

 

Get Installed Windows 10 Apps for all users
Get-AppxPackage -AllUsers

 

Get Installed Windows 10 Apps by Name for all users
Get-AppxPackage *weather* -AllUsers

 

Removing Windows 10 Apps by name
Get-AppxPackage *weather* | Remove-AppxPackage

 

Removing Windows 10 Apps by list
$AppList = @(

    "*Bing*",
    "*zune*"

)

foreach ($App in $AppList) {

    Get-AppxPackage -Name $App | Remove-AppxPackage

}
Removing Windows 10 Apps with an exception list
$ExceptionList = @(

    "*WindowsStore*",
    "*calc*"

)

Get-AppxPackage | Where { $App = $_; -not ( $ExceptionList | Where-Object { $App -like $_ } ) } | Remove-AppxPackage

Adding Windows 10 Apps

Now that we’ve mastered removing Windows 10 Apps, this is how we add Windows 10 Apps back. That is, if you ever decide to walk that lonely road.

Add Windows 10 App from Manifest
$AppName = "Weather"
$AppPath = @()
$AppPath += Get-ChildItem 'C:\Program Files\WindowsApps\' -Filter "*$AppName*x86*" | Select -ExpandProperty FullName
$AppPath += Get-ChildItem 'C:\Program Files\WindowsApps\' -Filter "*$AppName*x64*" | Select -ExpandProperty FullName

Add-AppxPackage -DisableDevelopmentMode -Register "$AppPath\AppxManifest.xml"

 

Add Windows 10 App from Provisioned Apps List
$ProvisionedList = (Get-AppxProvisionedPackage -Online).DisplayName
$AppPaths = @()
foreach ($App in $ProvisionedList) {

    $AppPaths += Get-ChildItem 'C:\Program Files\WindowsApps' -Filter "$App*x86*" | Select -ExpandProperty FullName
    $AppPaths += Get-ChildItem 'C:\Program Files\WindowsApps' -Filter "$App*x64*" | Select -ExpandProperty FullName

}

$AppPaths | ForEach-Object { 

    Add-AppxPackage -DisableDevelopmentMode -Register "$_\AppxManifest.xml" 

}

 

Removing Windows 10 App Provisions

While removing Windows 10 Apps is important, we need to prevent them from being added in the first place. Using the following code, you’ll be able to do just that.

 

Get Provisioned Windows 10 Apps
Get-AppxProvisionedPackage -Online

 

Get Provisioned Windows 10 Apps by Name
Get-AppxProvisionedPackage -Online | Where-Object {$_.DisplayName -like "*weather*"}

 

Removing Provisioned Windows 10 Apps by List
$AppList = @(

    "*bing*",
    "*zune*"

)

foreach ($App in $AppList) {

    Get-AppxProvisionedPackage -Online | Where-Object {$_.DisplayName -like $App} | Remove-AppxProvisionedPackage -Online

}

 

Things to keep in mind

Even though I said this at the start of the blog, it’s worth saying again, removing Windows 10 Apps happens per user

As of this moment, there is not a way to directly remove Windows 10 Apps for another user. As a result, there are a lot of blogs and forum posts on the internet with info that is wrong.

Yep. I said it. They’re wrong. Who could have ever guessed?! People are actually wrong on the internet!

Simply put, it’s because the Remove-AppxPackage cmdlet only works for the current user.

 

To sum it up, the above code will not remove SomePackage for all users. In fact, it will only remove the package from the current user.

Since we’re not doing a deep dive today, I’ll spare you the fancy details. But, if you’re curious, you’ll find a RemovePackageAsync method on the PackageManager class description page. That’s what Remove-AppxPackage uses.

In any case, this means you’ll have to use another method to get the apps removed from users who are not currently logged on. Here are a few ideas that we’ve come up with:

  • Putting a script in the startup folder (check out Jordan’s blog post)
  • Using Scheduled tasks
  • Using PDQ Deploy
  • Using Logon Scripts

Also, if you’re a fan of the DESTROY EVERYTHING approach, you may run into some issues. For example, Cortana and Edge browser are considered core apps and cannot be removed. So, you’ll have to plan ahead for what you want to remove.

In any case, have fun destroying all the things.

Happy PowerShelling!

Install Skype for Business with the OCT or Click-to-Run

Leave a commentDeployment Examples, PDQ Deploy

Tasked as you are to install Skype for Business so users can chit chat all the livelong day and collaboratively interface about marketing buzzwords, cotillions, bar mitzvahs, the annual Potato Festival, and probably work too, we have this fair post to help in your Skype for Business deployment adventure. If you are looking to uninstall Skype, we have a blog post for that too.

Using PDQ Deploy, there are two methods for deploying Skype for Business. One method is using the Office Customization Tool and the second is using the Office Deployment Tool (AKA Click-to-Run or C2R).

Install Skype for Business with the Office Customization Tool (OCT)

If you’re performing a fresh install of Office 2016 using the OCT, please see the Deploy Office 2016 KB. The option to install Skype for Business is included in the Office 2016 OCT configuration.

If you have already installed Office 2016 using the OCT and receive the Skype for Business quest, follow this handy walkthrough.

  1. Create another MSP using the same parameters except for the Set feature and installation states. Change the features as seen below:skype features and parameters
  2. Save the MSP. In our example, the MSP is saved as SkypeUpdate.MSP.
  3. Create a package in PDQ Deploy and add an Install step. Select the MSP file in the Install File field using the File Picker […]. The necessary parameters are added for you automatically because we are beings of light and magic. For more information on how to create the package with Conditions and Options, please see the Deploy Office 2016 KBsilently install skype for business
  4. Finally, complete your quest by deploying the package to computers with Office 2016 installed but missing the Skype for Business feature. Of course, we recommend testing first.

Install Skype for Business using Click-to-Run (C2R)

Don’t be daunted by the number of steps in this walk through. There’s no heavy lifting required, and it’s far easier to use C2R to install Skype for Business than it is to make macaroni and cheese from a box.

  1. Download the Office 2016 Deployment Tool (for C2R deployments) from Microsoft’s site.
  2. Create the necessary shared directory to serve the C2R/Skype for Business deployment: \\server\share\ (make sure the Deploy user has full share-level and NTFS permissions for the shared directory).
  3. Install the Office 2016 Deployment Tool for Click-to-Run, choose the extraction location to the previously created \\server\share\ .
  4. Copy the configuration.xml (installed with the Deployment Tool) to SkypeDownload.xml, or another name of your choosing, in the same directory.
  5. Now edit SkypeDownload.xml. Change OfficeClientEdition to “64” if you’re deploying the 64-bit rather than 32-bit version of Skype. Change the UNC of SourcePath to match the directory created in Step 2 above. Your XML should look something quite close to this:
    <Configuration>
     <Add SourcePath="\\server\share\" OfficeClientEdition="32">
     <Product ID="SkypeforBusinessRetail">
     <Language ID="en-us" />
     </Product>
     </Add>
    </Configuration> 
    
  6. Once you’ve saved the XML, open a command prompt, modify, and then run the following command (modifications may include using quotes if your paths contain spaces and changing SkypeDownload.xml if you used a different XML file name):
    "\\server\share\setup.exe" /download "\\server\share\SkypeDownload.xml"skype command prompt

    Wait for the download to complete. Grab a whiskey, commit to another shorter quest, or play Minesweeper. The files will be downloaded in an automatically generated directory called \\server\share\Office (you should not, and need not, create this directory beforehand). Once the download has completed, you will be returned to a prompt.

  7. Next, make another copy of the configuration.xml and name it something meaningful, like SkypeConfig.xml.
  8. Now edit SkypeConfig.xml and mirror any changes made in the step above (e.g. edition, branch). Your XML should look similar to this:
    <Configuration> 
     <Add OfficeClientEdition="32" Branch="Current">
     <Product ID="SkypeforBusinessRetail" > 
     <Language ID="en-us" /> 
     </Product> 
     </Add> 
    <Updates Enabled="TRUE" Branch="Current" />
    <Display Level="None" AcceptEULA="TRUE" />
    </Configuration>
  9. Now we create the package. In PDQ Deploy, create a new deployment and name it something meaningful.
  10. Next, add a Command step and modify to match your choices from above:
     "\\server\share\setup.exe" /configure "\\server\share\SkypeConfig.xml"skype config deploy

    Set the deployment Run As option to Deploy User (Interactive).deploy interactive skype for business

  11. Finally, save the package and then test the deployment (Right-click the completed package and select Deploy Once). If the results are acceptable, deploy at will and your quest is complete.

 

 

Notes and Addenda of Some Import:

  • The Office 2016 Deployment Tool (C2R) can be downloaded from Microsoft’s Site.
  • The Office 2016 Deployment Tool (C2R) supports these Product IDs.
  • The XML tag, <Property Name=”AUTOACTIVATE” Value=”0″ />, is not supported for Office 365 ProPlus products.
  • When installing Office products, it is always a good idea to deploy using the Run As option Deploy User (interactive).
  • The products listed in this article are for United States English (en-us). For use with other languages, please see the Microsoft Language Identifiers site.
  • The process for installing Skype for Business 2013 is similar to 2016. You will need to download the Office 2013 Deployment Tool as well as use the correct Product ID for the 2013 version, which is either LyncRetail or LyncEntryRetail.

Troubleshooting:

  • Error 1603. This error occurs most frequently when Skype for Business is either already installed or a version of Office exists that is not compatible with the version of Skype for Business you are installing.
  • Make certain you are installing the appropriate product as expressed by the Product ID defined by Microsoft. Skype for Business has two Office 2016 options: SkypeforBusinessRetail and SkypeforBusinessEntryRetail.

See Also…
Words:
Deploy Office 2016 Using The Microsoft Office Customization Tool
Deploy Office 365
Videos:
Silently Installing Office 365
Admin Arsenal Live! : Uninstalling Microsoft Office with PDQ Deploy
Admin Arsenal Live! : Adding and Removing Microsoft Office Components
Configuring and Deploying the Microsoft Office Customization Toolkit
Preparing The Office Customization Toolkit For Deployment
Deploy the Office Customization Toolkit Remotely
Microsoft:
Product IDs that are supported by the Office Deployment Tool for Click-to-Run
Office 2016 Deployment Tool
Office 2013 Deployment Tool
Language Identifiers

Registry Scanner

Leave a commentPDQ Inventory, Scanning

If you’re looking for an easier way to scan the registry of your computers, you are at the right place. There are just a few steps to take to set up a Scan Profile with a registry scanner to find what you are looking for. Watch a video tutorial, or follow the steps below.

Setting Up Your Registry Scanner

  1. Go to File > Preferences > Scan Profile. Here you can create a new Scan Profile (Click New), or alternatively, you can add a registry scanner to an existing profile (Highlight a Scan Profile and click Edit). scan profile preferences
  2. Click Add > Registry to begin building your registry scanner. Note the available wildcards you can use to narrow down your search. RegistryScannerEdit
  3. Click OK to add the registry scanner to your selected profile. If you’re done adding scanners click OK again to return to the Preferences screen. Registry scanner - RegistryProfileExample
  4. Now you’re ready to use your newly updated or created Scan Profile. After exiting out of Preferences, in the main window click the Scan icon and select your Scan Profile to run against your selected computers. (In this example, a new Scan Profile was created and named Misc. Registry. Remember you can add a registry scanner to any existing Scan Profile or build a Scan Profile with multiple scanners in it.) Run New Registry Profile

Viewing Your Registry Scanner Results

Now that you’ve got your Scan Profile set up and have run it against your computers, now it’s time to create a report. In the top toolbar you’ll see a drop down that allows you to create a new report.

The example below shows the filters for a report that shows computers that have a 32-bit version of Chrome. Obviously, depending on what you are looking for in the registry your report will look quite different and require different filters. To master using filters in reports, we highly recommend you watch this playlist on using filters or you can also watch our recent webcast on Advanced Reporting in PDQ Inventory.

Google Report 32 bit



Advanced Reporting in PDQ Inventory

Leave a commentPDQ Inventory

Thanks to everyone who joined our webcast live. Below are downloads you can import into PDQ Inventory as well as other helpful videos and links relating to creating reports in PDQ Inventory.

XML Downloads

Reports – Advanced Reporting

Reports-Pattern vs Expression

Scan Profile-DHCP/Static Registry

Videos

Playlist: Filters for Collections and Reports

Advanced Reports in PDQ Inventory using SQL

Links

Import Custom Fields in PDQ Inventory Using the Custom Fields Import Wizard

Inventory Files Scanner: Examples & Usage

Inventory Registry Scanner: Usage & Examples

Auto Reports

Documentation

Video: Creating Auto Reports in PDQ Inventory

Determining Disk Type with Get-PhysicalDisk

2 CommentsPowerShell

After today, you are going to know that determining disk type with Get-PhysicalDisk is super easy.

If you recently watched our PDQ & A webcast, you may have seen that we were unable to answer a question about how to determine if a disk is a solid state drive (SSD) or not.

Fast forward to now and we have that answer by utilizing Get-PhysicalDisk cmdlet.

Thanks PowerShell!

Gathering Physical Disk Information with Get-PhysicalDisk

If you’re using Windows 8 or later, you can get all the information you could ever want to know about your physical disk but were afraid to ask by running this (very) simple command:

Get-PhysicalDisk | Select *

Blog - SSD or not - Get-PhysicalDisk example with all properties

Determining Disk Type with Get-PhysicalDisk

Armed with this new knowledge, of how to use Get-PhysicalDisk, let’s find out which (if any) of my physical disks are SSD.

Get-PhysicalDisk | Select FriendlyName, MediaType

Blog - SSD or not - Get-PhysicalDisk example

Ta da!  Like magic, you can now determine your disk types!  That is, only if you’re using Windows 8 or higher. Should you happen to be stuck on older versions of windows, then you’ll just have to pretend to follow and/or sing along.

By default, just running Get-PhysicalDisk will not get you the MediaType, so be sure to select it specifically.

That’s it. We’re done. You can go home now and show off your new and powerful knowledge to your friends and neighbors.

There’s nothing more to see here. That is, unless you want to learn more! *gasp!*

Slightly Deeper Dive

Since it’s not a true deep dive, perhaps we should call this the casual saunter into the the shallow end of the pool of knowledge. If you’re still reading this far, we’ll show you the class that Get-PhysicalDisk appears to be using to gather those fancy properties.

In addition to the Get-PhysicalDisk cmdlet, we found that the MSFT_PhysicalDisk appears to provide exactly what we’re looking for (link about the class). Knowing the class, here is how you would query that information with PowerShell:

Get-WmiObject -Class MSFT_PhysicalDisk -Namespace root\Microsoft\Windows\Storage  | Select FriendlyName, MediaType

Blog - SSD or not - MSFT_PhysicalDisk example

Unsurprisingly, this looks very similar to the result we got with Get-PhysicalDisk. Now, we just need to know what the media types 3 and 4 actually mean.

Based on this page about the MSFT_PhysicalDisk class (link here – Look for MediaType section), we can see which media types are available and what their values mean.

3 = HDD
4 = SSD

Since we know what these values now mean, we can modify our PowerShell above to use some calculated properties (fancy!) and include a simple switch statement to display friendlier results. Joy!

Get-WmiObject -Class MSFT_PhysicalDisk -Namespace root\Microsoft\Windows\Storage | 
     Select FriendlyName,
     SerialNumber,
     @{
         name="MediaType"; 
         expression={
             switch ($_.MediaType) { 
                 3 {"HDD"}
                 4 {"SSD"} 
             } 
         }
     }

Blog - SSD or not - MSFT_PhysicalDisk example with calculated propertie

Running the code above will show each physical disk and the associated media type. Amazing!

Alternatively, you could break this into multiple commands instead of the single command. But, that would have robbed me of the opportunity to use calculated properties.

Wrapping up

Like I mentioned before, I recommend that you use the first example since it’s much easier to remember and use:

Get-PhysicalDisk | Select FriendlyName, MediaType

As Always, go forth and PowerShell!

 

Managing Domain Memberships with PowerShell

2 CommentsDeployment Examples, PDQ Deploy

Let’s go through some steps that may prove helpful in speeding up your processes in joining machines to a domain, or helping you to migrate machines to a new domain at scale. We will utilize some pretty simple PowerShell to accomplish this task. So without further ado, grab a drink, sit back, and let’s do this!

Checking Domain Membership

We need some logic to see if the machine is currently a member of a domain. That’s pretty simple with PowerShell. The code looks like this (and will return a true/false value):

(Get-WMIObject win32_computersystem).partofdomain

Removing a Machine from a Domain

This also is going to return to us a true/false value. Given that we want to put the machine on a new domain, let’s use some logic to automate removing the machine from its current domain membership.

If ( (Get-WMIObject win32_computersystem).partofdomain "eq $true ){
    Remove-Computer
}

Pretty simple right? The machine is now off the domain! However, you may need to restart the computer for the changes to apply. You can add a -restart parameter to your script if desired. Keep in mind that this will only tell the local computer to switch to using a workgroup. It doesn’t clean anything up in Active Directory. It will only disable the associated computer object in Active Directory.

Some additional parameters to consider:

-UnjoinDomainCredential

This is for specifying a user account that has permission to remove computers from their current domain. This is a required parameter if you’re trying to use Remove-Computer with a remote computer.

-LocalCredential

This parameter is for specifying a user account with permission to connect to the computer

Putting a Machine on a New Domain

The question then becomes “Well, how do I put it on the new domain?” I’m so glad you asked! Let’s look at that:
A couple of prerequisites are needed. To add a computer to the domain, we must supply credentials to the command that have been delegated rights to add machines to the domain. There are a few ways to do this, and I will provide the simplest method in this post, though I would recommend reading Kris’ excellent post on using more secure credentials here. Let’s go ahead and get our account setup in PowerShell.

$User = "DOMAIN\DelegatedUser"
$Password = ConvertTo-SecureString "somepassword" "AsPlainText "Force
$Credentials = New-Object System.Management.Automation.PSCredential $user,$password

Now we can pass that set of credentials to the next cmdlet we need to utilize:

Add-Computer "Domainname "YourDomainName" -Credential $Credentials

Restart Options

The computer will need a reboot after the task is complete. You have some options here. You can use a Restart-Computer cmdlet in your script right after Add-Computer, or if deploying your script with PDQ Deploy you can add a Reboot Step to your deployment package. The Reboot step is my preferred method, as that will let PDQ Deploy control deployment state, and return a successful result when the computer checks back in after the reboot is complete. Otherwise, if you choose to add Restart-Computer cmdlet directly into your script, you have no way of receiving any feedback from the script being run. It will simply timeout (though the target machine will be rebooted).

A simple way to put this together would be to make a PowerShell function that joins the machine to the domain. This makes it easy.

Let’s put that all together so you have a clear picture of what the complete script would look like:

$User = "DOMAIN\DelegatedUser"
$Password = ConvertTo-SecureString "somepassword" "AsPlainText "Force
$Credentials = New-Object System.Management.Automation.PSCredential $User,$Password

Function Join-Domain {
    Add-Computer "Domainname "" -Credential $Credentials
}

If ( (Get-WMIObject win32_computersystem).partofdomain "eq $true ) {
    Remove-Computer
    Join-Domain
} Else {
    Join-Domain
}

Deploying Your PowerShell Script

One option for deploying your script is to use PDQ Deploy. Save this script as a ps1 file somewhere on your network, such as your PDQ Repository.

  1. Create a new package, give it a name, and add a PowerShell step to the package.Powershell Step Window.
  2. Give the step a title, and then select Insert PowerShell Script at the bottom of the command window on the details tab.Powershell Step Insert Script managing domain memberships
  3. Browse to and select your PowerShell script you created from the code above. Set your conditions and options as you see fit for your environment.
  4. Deploy to your target machines with a Local Administrator account. (We don’t want any hiccups once the machine is off the domain.)Change Deploy Credentials