PoshCode Archive  Artifact Content

Artifact 59bc5d4edc6626a99a70d6f75798d99821283e3461c9fe8e69db58413eee8d66:

  • File Updates-group-policy.ps1 — part of check-in [792893327c] at 2018-06-10 13:45:03 on branch trunk — Updates group policy on remote domain computer,(Can be modified easily to include all computers or a list.). I wrote this for our field techs, simple but useful. (user: Johnny Reel size: 1268)

# encoding: ascii
# api: powershell
# title: Updates group policy 
# description: Updates group policy on remote domain computer,(Can be modified easily to include all computers or a list.). I wrote this for our field techs, simple but useful.
# version: 1.0
# type: module
# author: Johnny Reel
# license: CC0
# x-poshcode-id: 4722
# x-archived: 2013-12-22T06:56:45
# x-published: 2013-12-19T19:26:00
#
#
# GpupdateADcomputer
# Synopsis: Updates group policy on remote domain computer,(Can be modified easily to include all computers or a list.).
# Johnny Reel
# V1.0
# Requirements PowerShell v2.0 / Administrative rights on target(s).
# 
# Example: .\GpupdateAdComputer.ps1
# Use domain\credential when prompted.
# Output: Updating Policy...
# User Policy update has completed successfully.
# Computer Policy update has completed successfully.

Import-Module -Name ActiveDirectory

# Insert computer name in the quotes or modify to accept a list. Use -Filter * in place of 'Name -like "<computer>"' to update all domain computers. 

$cn = Get-ADComputer -Filter 'Name -like "<computer>"'
$cred = $User
$session = New-PSSession -ComputerName $cn.Name -Credential $cred
Invoke-Command -Session $session -ScriptBlock {gpupdate /force}