Archive for the ‘Powershell’ Tag

Update all AZ. Azure Powershell Modules #PowerShell #Azure #Script #modules   Leave a comment

If you do a lot with Azure and PowerShell you may noticed that the latest module is important. as functions may not be there or properties are not listed correctly.

There are plenty of scripts around on how to update these modules. 

With the  Get-InstalledModule you will get a list of the modules on your system

image

When doing get module with the –listAvailable you will see all the versions

Get-Module -Name az.* -ListAvailable

image

here is the powershell code Like I said before there are tons of the same scripts around on github or blog post. So don’t invent the wheel again reuse and modify to your needs

Get-Module -Name az.* -ListAvailable |
  Where-Object -Property Name -ne ‘Az.’ |
  ForEach-Object {
    $currentVersion = [Version] $_.Version
    $newVersion = [Version] (Find-Module -Name $_.Name).Version
    if ($newVersion -gt $currentVersion) {
      Write-Host -Object "Updating $_ Module from $currentVersion to $newVersion"
      Update-Module -Name $_.Name -RequiredVersion $newVersion -Force
      Uninstall-Module -Name $_.Name -RequiredVersion $currentVersion -Force
    }
  }

Running this can tike some time as you can see In this case I have a lot of old and new modules and these are being updated to the latest versions

image

When updating this I had some PowerShell windows still open and got some errors, you can also do this by hand.

For sample  – Install-Module -Name Az.Accounts -RequiredVersion 1.8.0 –Force

image

Hope this helps you to a better Azure PowerShell experience. 

 

 

Follow Me on Twitter @ClusterMVP

Follow My blog https://robertsmit.wordpress.com

Linkedin Profile Robert Smit MVP Linkedin profile

Google  : Robert Smit MVP profile

Posted May 27, 2020 by Robert Smit [MVP] in Azure

Tagged with ,

Get #windows 10 digital license with #Powershell #winserv #OSD #WDS   2 comments

When rebuilding your windows 10 desktop that hold a digital license key there is no piece of paper that tells you the activation key.

with the following command you can read the product key

$service = get-wmiObject -query ‘select * from SoftwareLicensingService’
$service.OA3xOriginalProductKey
$key=$service.OA3xOriginalProductKey

this is handy for getting the key but when you are deploying a WDS image and everything needs to be unattended you will need a little PowerShell script

As an option there to place a different key for if you are in a mixed environment.

$service = get-wmiObject -query ‘select * from SoftwareLicensingService’
$service.OA3xOriginalProductKey
$key=$service.OA3xOriginalProductKey
$service.InstallProductKey($key)

$service = get-wmiObject -query ‘select * from SoftwareLicensingService’
if($key = $service.OA3xOriginalProductKey){
    Write-Host ‘Activating using product Key:’ $service.OA3xOriginalProductKey
    $service.InstallProductKey($key)
}else{

    #Write-Host ‘Key not found., use a different license’
       # $service.InstallProductKey(‘Put your License KEY here’)
}

 

Save this as a Powershell script and put this in the unattended.xml and when deploying the Windows 10 will be auto activated

Get the script from the site or from the TechNet gallery.

https://gallery.technet.microsoft.com/Get-windows-10-digital-7653fae4

 

Follow Me on Twitter @ClusterMVP

Follow My blog https://robertsmit.wordpress.com

Linkedin Profile Http://nl.linkedin.com/in/robertsmit

Google Me : https://www.google.nl

Bing Me : http://tinyurl.com/j6ny39w

LMGTFY : http://lmgtfy.com/?q=robert+smit+mvp+blog

Posted March 19, 2017 by Robert Smit [MVP] in Powershell

Tagged with

  • Twitter

  • RSS Azure and Microsoft Windows Server Blog

  • %d bloggers like this: