Bart's Weblog

Just a blog…

Archive for the ‘Scripting’ Category

WSUS: Automatically Declining Itanium Updates

Posted by bartvdw on 0606/0505/2013

This is quiet useful, and easier then using the GUI to filter them out…

Automatically Declining Itanium Updates in WSUS
http://gallery.technet.microsoft.com/scriptcenter/Automatically-Declining-a4fec7be

Adapt the code if you don’t want to have an email sent (ex. output to screen or dump in a text file).

Posted in PowerShell, WSUS | 5 Comments »

Citrix: Documenting a Citrix XenApp 6.5 Farm with Microsoft PowerShell

Posted by bartvdw on 0606/0505/2013

Documenting a Citrix XenApp 6.5 Farm with Microsoft PowerShell
http://carlwebster.com/documenting-a-citrix-xenapp-6-5-farm-with-microsoft-powershell/

Posted in Citrix, PowerShell | Leave a Comment »

Citrix: List all installed Hotfixes and Rollup Packs (PowerShell) (XenApp)

Posted by bartvdw on 0606/0505/2013

Citrix XenApp Powershell : List all installed Hotfixes and Rollup Packs
http://www.brichet.be/?p=393

If you for example only wants a list of updates, change the command like follows (example):

$Hotfixes = Get-XAServerHotfix $Server.ServerName | Select HotfixName

If you receive an error regarding “Out-GridView”, remove that line and run the script using “> output.txt” or use another method.

Posted in Citrix, PowerShell | Leave a Comment »

WSUS: PoshPAIG (PowerShell Patch Audit/Installation GUI)

Posted by bartvdw on 0606/0505/2013

PoshPAIG (PowerShell Patch Audit/Installation GUI)
http://poshpaig.codeplex.com

Posted in Microsoft, PowerShell, WSUS | Leave a Comment »

PowerShell: WSUS cleanup script

Posted by bartvdw on 0808/0606/2012

This script allows you to schedule WSUS cleanup on a regular basis.

[reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration") | out-null
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer();
$cleanupScope = new-object Microsoft.UpdateServices.Administration.CleanupScope;
$cleanupScope.DeclineSupersededUpdates = $true       
$cleanupScope.DeclineExpiredUpdates         = $true
$cleanupScope.CleanupObsoleteUpdates     = $true
$cleanupScope.CompressUpdates                  = $true
#$cleanupScope.CleanupObsoleteComputers = $true
$cleanupScope.CleanupUnneededContentFiles = $true
$cleanupManager = $wsus.GetCleanupManager();
$cleanupManager.PerformCleanup($cleanupScope);

WSUS Cleanup
http://gallery.technet.microsoft.com/ScriptCenter/fd39c7d4-05bb-4c2d-8a99-f92ca8d08218/

Posted in PowerShell, WSUS | Leave a Comment »

PowerShell: Return wandering VMs to their preferred ESX host

Posted by bartvdw on 0303/0909/2011

For the people that want to place VMs at specific ESX hosts, the scripts in the link below will make your life easy!

Return wandering VMs to their preferred ESX host

Posted in PowerShell, VMware | Leave a Comment »

PowerShell: Outlook unified signature based on Active Directory information

Posted by bartvdw on 0303/0909/2011

I came across this nice PowerShell solution to have unified Outlook signature based on Active Directory information in your company. Check it out!

Outlook signature based on user information from Active Directory

Deploying a Unified Email Signature Template in Outlook

Microsoft TechNet Script Center link: Outlook signature based on user information from Active Directory

Posted in Active Directory, Outlook, PowerShell | Leave a Comment »

PowerShell: Protect all OU’s in Active Directory from accidental deletion

Posted by bartvdw on 1313/0808/2011

1) Check which OUs aren’t protected:
Get-ADOrganizationalUnit -filter * -Properties ProtectedFromAccidentalDeletion | where {$_.ProtectedFromAccidentalDeletion -eq $false} | ft

2) Protect them:
Get-ADOrganizationalUnit -filter * -Properties ProtectedFromAccidentalDeletion | where {$_.ProtectedFromAccidentalDeletion -eq $false} | Set-ADOrganizationalUnit -ProtectedFromAccidentalDeletion $true

3) Then rerun the first command to verify they have been changed.

These commands should run with "Active Directory Module for Windows PowerShell" for AD only or "PowerShell Modules" to load all of them.

AD DS: All OUs in this domain should be protected from accidental deletion
http://technet.microsoft.com/en-us/library/dd723677%28WS.10%29.aspx

Posted in Active Directory, PowerShell | 9 Comments »

PowerShell: How to retrieve disk size & free disk space for a list of computers (input file)

Posted by bartvdw on 1919/0606/2008

Note: works only with V2 which is currently in CTP stage!

The command below will show you a very nice overview of disk size & free space for a list of computers (input file). The great thing about PowerShell, from my point of view, is “piping” commands into 1 big command which eliminates the need to create a script for certain operations. Secondly in V2 (CTP), the “gridview” option is amazing!

Get-WMIObject Win32_LogicalDisk -filter “DriveType=3″ -computer (Get-Content c:\scripts\computers.txt) | Select SystemName,DeviceID,VolumeName,@{Name=”size(GB)”;Expression={“{0:N1}” -f($_.size/1gb)}},@{Name=”freespace(GB)”;Expression={“{0:N1}” -f($_.freespace/1gb)}} | Out-GridView

Posted in PowerShell, Scripting | 39 Comments »

PowerShell: ExecutionPolicy

Posted by bartvdw on 2222/0404/2008

I know I waited far too long to start working with PowerShell. But OK, here we are. And immediately encountered something. By default it sets some security related to running scripts. Only when I did what it said, I was unable to change that security!

OK in short, after you install PowerShell, it sets the “ExecutionPolicy” for scripts to “Restricted”, which means you’re not allowed to execute scripts. Not very interesting… So I used the “Set-ExecutionPolicy RemoteSigned” command to change, but this returned an error:
Set-ExecutionPolicy : Access to the registry key ‘HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell’ is denied.
At line:1 char:20
+ Set-ExecutionPolicy  <<<< RemoteSigned

  • Open registry
  • Browse to key HKLM\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell
  • If “ExecutionPolicy” does not exist, create it as REG_SZ with value “RemoteSigned”
  • Open PowerShell and use the command “Get-ExecutionPolicy” to see it is done correctly

It’s only obvious that if another security level is desired, you adapt the value… 🙂

Posted in PowerShell, Scripting | 14 Comments »