-1

I'm having an issue with this script. For some reason, it was working previously and now it is not. It is now returning with:

Invoke-GPUpdate : The term 'Invoke-GPUpdate' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Write-Host "Refreshing Group Policies on the local machine......."

Invoke-GPUpdate -Computer $computer -RandomDelayInMinutes 0 -force ForegroundColor Cyan

Start-Sleep -s 20

starball
  • 20,030
  • 7
  • 43
  • 238

1 Answers1

4

Invoke-GPUpdate is part of the GroupPolicy module. GroupPolicy is not available by default, but is included with RSAT Tools. What likely happened is a major update to Windows occurred and in this case, if RSAT Tools isn't installed as a Windows Feature (it is only available as a "Feature on Demand" beginning with the Windows 10 October 2018 Update, which is build 17763), it will get removed during the update and needs to be re-installed.

This technically happens with the feature as well I believe, as RSAT Tools is still linked to specific versions of Windows, but the upgrade process will re-install the feature if it was already present.

Installing GroupPolicy RSAT Tools as a feature with Windows PowerShell

If you have Windows 1809 or newer, you can install as a feature using the following command:

Get-WindowsCapability -Name 'Rsat.GroupPolicy.*' -Online | Where-Object { $_.State -ne 'Installed' } | Add-WindowsCapability -Online

You can do the same with other RSAT Tools as well (the features are modularized per their functionality). To enumerate all of them:

Get-WindowsCapability -Name RSAT*

Once again, this requires Windows 1809 or newer or the features will be unavailable. You'll have to install it by using the MSU provided by Microsoft for your Windows version.

codewario
  • 19,553
  • 20
  • 90
  • 159