How Do You Use PowerShell to Find out if a Given Update Has Been Installed on Your Windows Workstation?

Problem scenario
You want to know if a particular KB was installed on your Windows machine. You know the KB number. How do you use PowerShell to find out if this update has been installed or not?

Solution
Run this: get-hotfix | sls “kb123456789” # Replace kb123456789 with the KB of your choice.

 » Read more..

How Do You Create the PowerShell Script, the Template.json and the Parameters.json Necessary to Utilize ARM?

Problem scenario
To use ARM templates you know know you should have three text files: 1) a PowerShell script 2) a template.json file and 3) a parameters.json file.

How do you create these for a given resource (e.g., a storage account, VM, or Function App)?

Solution
1.  In the Azure Portal web UI, start the process of creating a resource.  Right before you click “Create”,

 » Read more..

How Do You Use an ARM Template to Create an Azure Serverless Function App?

Problem scenario
As a proof-of-concept you want to use an ARM template to create an Azure Function that uses Azure storage.  You want the template to create the Azure storage account as it is a dependency of the Azure Serverless Function (also known as an App Service).  How do you do this?

Overview
This will create an Azure Function also known as an App Service. 

 » Read more..

How Do You Create a PowerShell Script to Create a Storage Account in Azure?

Problem scenario
You want to use an ARM template via a PowerShell script to create a storage account in Azure.  How do you do this?

Solution
Prerequisites

1.  If you are using Windows 7, you have installed Azure PowerShell; if you need assistance with this, see this posting.  If you are using Windows 10, you have installed the modules for Azure and the storage resource;

 » Read more..

How Do You Install Azure PowerShell on Windows 10?

Problem scenario
You want to run ARM templates to declaratively create resources such as servers, databases, and subnets in Azure.  You need the PowerShell module for Azure to be installed for certain “reserved” words to work.  How do you install the Azure PowerShell?

Solution
1.  Open PowerShell as administrator.  (PowerShellGet is built into Windows 10 by default.  It may appear uninstalled, but it is natively part of the OS.)
2. 

 » Read more..

How Do You Find the Subscription ID for an Azure Account?

Problem scenario
You want to find the subscription ID for your Azure account.  What do you do?

Possible Solution #1
Log into the Azure Portal.  In the upper right click on your account and then click on “My permissions.”  You should see an alphanumeric string near your subscription.

Possible Solution #2
Prerequisite

If you have Windows 7 you need to install Azure PowerShell;

 » Read more..

How Do You Troubleshoot the PowerShell Error “Cannot connect to CIM Server: Access is denied”?

Problem scenario
You run a PowerShell command with a user who is not a local administrator on the server.  You get the error “Cannot connect to CIM server: Access is denied”.  How do you circumvent this error?

Possible solution #1
Make the user a local administrator.  Then try again.

Possible solution #2
Use JEA to allow the user to run the command. 

 » Read more..

How Do You Troubleshoot the Powershell Error “Cannot find Get-Command”?

Problem scenario
You run a PowerShell command.  You get “Cannot find Get-Command” even though the command you entered was not Get-Command.  How do you solve this error?

Possible Solution #1
As an Admininstrator of the server, go to Server Manager -Tools -Computer Management.  In this Window (or MMC) go to System Tools -Local Users and Groups -Users. 

 » Read more..

How Do You SSH to a Windows Server or How Do You Install Cygwin on a Windows 2016 Server?

Problem scenario
You want to install Cygwin to allow for SSH connections (from Linux servers) to your Windows server.  How do you do this?

Solution
1.  If the server is new, skip step #1.

  a)  Log in and go to Control Panel -> System and Security -> System.  Click on “Advanced system settings” on the left.

  b)  Go to the Advanced tab and click on “Environment Variables…”

 

 » Read more..

How Do You Get PowerShell’s Invoke-Webrequest to Work Consistently (Instead of “command not found”)?

Problem scenario
You use invoke-webrequest and it works fine with some websites. But sometimes you find that PowerShell says “command not found.”  What is wrong?

Solution
invoke-webrequest will work to download html and htm files.  Depending on the source file on the web server, the command needs a flag to work properly.  For an image file with a .jpeg extension, the invoke-webrequest needs a flag “-ContentType ‘image/jpg'” or something similar to work. 

 » Read more..