Pages

6/24/2011

check server time zones

##########################################################################################
# CHECK-TZONE.PS1
#
# Report local time and time zone for list of servers
#
##########################################################################################

$colResults = get-content C:\UTIL\WSUS-GROUPS\WSUS-USA-REMOTE.TXT
$time_zones = @()
clear-host
 "SERVER TIME ZONES"  
 ""
 "SERVER          `tTIME    `t TIME ZONE"
 "----------------`t--------`t --------------------------------------"
 
foreach ($result in $colResults) {
  $hour = ""
  $min = ""
  $sec = ""
  $comp = ""
  $t = ""
   $computer = $result 
  $comp = "{0,-16}" -f $computer
  $timezone = Get-WMIObject -class Win32_TimeZone -ComputerName $computer -erroraction SilentlyContinue
  $dt = gwmi win32_localtime -computer $computer -erroraction SilentlyContinue
  [string] $hour = [System.Convert]::ToString($dt.Hour)
  $hour = $hour.padleft(2,"0")
  [string] $min = [System.Convert]::ToString($dt.Minute)
  $min = $min.padleft(2,"0")
  [string] $sec = [System.Convert]::ToString($dt.Second)
  $sec = $sec.padleft(2,"0")
  $t = $hour + ":" + $min + ":" + $sec
  if ($dt) { write-host "$comp`t$t`t" $timezone.Description }
}

6/22/2011

This script installs the Operations Management Server PowerShell SnapIn onto a given computer

Install SCOM SnapIn: "This script installs the Operations Management Server PowerShell SnapIn onto a given computer"
#=============================================================================#
#                                                                             #
# Install-SCOMSnapIn.ps1                                                      #
# Powershell Script to install Operations Management Server SnapIn            #
# Author: Jeremy Engel                                                        #
# Date: 04.13.2011                                                            #
# Version: 1.1.0                                                              #
#                                                                             #
#=============================================================================#

Param([Parameter(Mandatory = $true)]$Computer,
      [Parameter(Mandatory = $true)]$ManagementServer
      )

$fileRepository = "\\$ManagementServer\c$\Program Files\System Center Operations Manager 2007"
$rootPath = "C:\Program Files\System Center Operations Manager 2007\SnapIn"

$files = @("Microsoft.EnterpriseManagement.OperationsManager.ClientShell.dll",
           "Microsoft.EnterpriseManagement.OperationsManager.ClientShell.dll-help.xml",
           "Microsoft.EnterpriseManagement.OperationsManager.ClientShell.Format.ps1xml",
           "Microsoft.EnterpriseManagement.OperationsManager.ClientShell.Types.ps1xml"
           )
$sdkfiles = @("Microsoft.EnterpriseManagement.OperationsManager.Common.dll",
              "Microsoft.EnterpriseManagement.OperationsManager.dll"
              )

function Main {
  $remotePath = $rootPath.Replace("C:","\\$Computer\c$")
  if(!(Test-Path $remotePath)) { $null = New-Item $remotePath -Type Directory }
  foreach($file in $files) { 
    if(!(Test-Path "$remotePath\$file")) { 
      Copy-Item -Path "$fileRepository\$file" -Destination $remotePath
      }
    }
  foreach($file in $sdkfiles) {
    if(!(Test-Path "$remotePath\$file")) {
      Copy-Item -Path "$fileRepository\SDK Binaries\$file" -Destination $remotePath
      }
    }
  $hklm = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine,$Computer)
  $scom = $hklm.CreateSubKey("SOFTWARE\Microsoft\PowerShell\1\PowerShellSnapIns\Microsoft.EnterpriseManagement.OperationsManager.Client")
  $scom.SetValue("ApplicationBase",$rootPath,"String")
  $scom.SetValue("AssemblyName","Microsoft.EnterpriseManagement.OperationsManager.ClientShell, Version=6.0.4900.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","String")
  $scom.SetValue("ModuleName","$rootPath\Microsoft.EnterpriseManagement.OperationsManager.ClientShell.dll","String")
  $scom.SetValue("PowerShellVersion","1.0","String")
  $scom.SetValue("Vendor","Microsoft Corporation","String")
  $scom.SetValue("Version","6.0.4900.0","String")
  $scom.SetValue("Description","Microsoft Operations Manager Shell Snapin","String")
  $scom.SetValue("Types","$rootPath\Microsoft.EnterpriseManagement.OperationsManager.ClientShell.Types.ps1xml","String")
  $scom.SetValue("Formats","$rootPath\Microsoft.EnterpriseManagement.OperationsManager.ClientShell.Format.ps1xml","String")
  }

Main

6/21/2011

Tweaking Windows 7 / Vista TCP/IP settings

SpeedGuide.net :: Windows 7, Vista, 2008 Tweaks: "Tweaking Windows 7 / Vista TCP/IP settings"
Disable Windows Scaling heuristics

Windows Vista/7 has the ability to automatically change its own TCP Window auto-tuning behavior to a more conservative state regardless of any user settings. It is possible for Windows to override the autotuninlevel even after an user sets their custom TCP auto-tuning level. When that behavior occurs, the "netsh int tcp show global" command displays the following message:


** The above autotuninglevel setting is the result of Windows Scaling heuristics
overriding any local/policy configuration on at least one profile.

To prevent that behavior and enforce any user-set TCP Window auto-tunning level, you should execute the following command:


netsh int tcp set heuristics disabled

possible settings are: disabled,enabled,default (sets to the Windows default state)
recommended: disabled (to retain user-set auto-tuning level)

Note this should be executed in elevated command prompt (with admin priviledges) before setting the autotuninlevel in next section. If the command is accepted by the OS you will see an "Ok." on a new line.

The corresponding Registry value (not necessary to edit if setting via netsh) is located in:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters
EnableWsd=0   (default: 1, recommended: 0)


TCP Auto-Tuning

To turn off the default RWIN auto tuning behavior, (in elevated command prompt) type:

netsh int tcp set global autotuninglevel=disabled

The default auto-tuning level is "normal", and the possible settings for the above command are:

disabled: uses a fixed value for the tcp receive window. Limits it to 64KB (limited at 65535).
highlyrestricted: allows the receive window to grow beyond its default value, very conservatively
restricted: somewhat restricted growth of the tcp receive window beyond its default value
normal: default value, allows the receive window to grow to accommodate most conditions
experimental: allows the receive window to grow to accommodate extreme scenarios (not recommended, it can degrade performance in common scenarios, only intended for research purposes. It enables RWIN values of over 16 MB)

Our recommendation: normal (unless you're experiencing problems).

If you're experiencing problems with your NAT router or SPI firewall, try the "restricted", "highlyrestricted", or even "disabled" state.

Notes:
- Reportedly, some older residential NAT routers with a SPI firewall may have problems with enabled tcp auto-tuning in it's "normal" state, resulting in slow speeds, packet loss, reduced network performance in general.
- auto-tuning also causes problems with really old routers that do not support TCP Windows scaling. See MSKB 935400
- netsh set commands take effect immediately after executing, there is no need to reboot.
- sometimes when using "normal" mode and long lasting connections (p2p software / torrents), tcp windows can get very large and consume too much resources, if you're experiencing problems try a more conservative (restricted) setting.

Disable TCP autotuning

How to disable the TCP autotuning diagnostic tool: "How to disable the TCP autotuning diagnostic tool"

6/17/2011

Put list of servers in SCOM maintenance mode

- have a folder which contains text files with lists of servers to define groups.
$rootMS = "PRIRMS01"
$Folder="c:\util\wsus-groups\"

"SET MAINTENANCE MODE"
"LISTS:"
$list = get-childitem $Folder -Name 
$list = $list -replace ".TXT",""
$list | format-wide {$_} -Column 3 -Force

$group = Read-Host "LIST [WSUS-Test-Group-2]"
if (!$group) { $group = "WSUS-Test-Group-2" }
$t = Read-Host " TIME[60]"
if (!$t) { $t = "60" }
$comment = Read-Host "COMMENT [Windows Updates]"
if (!$comment) { $comment = "Windows Updates" }

#####################################
#attach SCOM SnapIn
Add-PSSnapin "Microsoft.EnterpriseManagement.OperationsManager.Client" -ErrorVariable errSnapin; 
Set-Location "OperationsManagerMonitoring::" -ErrorVariable errSnapin; 
new-managementGroupConnection -ConnectionString:$rootMS -ErrorVariable errSnapin; 
set-location $rootMS -ErrorVariable errSnapin;
#

$File = $Folder + $group + ".TXT"
$servers = get-content $File
"Setting maintenance mode for $t minutes:"
foreach ($server in $servers) {
write-host "    $server" -nonewline
    $strServer = Get-Agent | Where-object {$_.Name -match $server}
    if (!$strServer) { write-host " - ERROR finding SCOM Agent!" -nonewline }
    if ($strServer) { $strServer.HostComputer | New-MaintenanceWindow -StartTime (Get-Date) -EndTime (Get-Date).AddMinutes($t)-Comment $comment }
 write-host ""
    }

"COMPLETE"
Write-Host "Press any key to continue ..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

6/09/2011

POWERSHELL List Updates in WSUS

[void][reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration")
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer('WSUS02',$False,80)
#Get all updates
$updates = $wsus.GetUpdates()
#Iterate every update and output some basic info about it
$collection = @()
ForEach ($update in $updates) {
#$update
$product = $update.ProductTitles
$product.type
 $obj = New-Object System.Object
 $obj | Add-Member -type NoteProperty -name Date -value $update.CreationDate.ToString()
 $obj | Add-Member -type NoteProperty -name Approved -value $update.IsApproved.ToString()
 $obj | Add-Member -type NoteProperty -name Class -value $update.UpdateClassificationTitle
 $obj | Add-Member -type NoteProperty -name Product -value $product
 $obj | Add-Member -type NoteProperty -name Title -value $update.Title
 $collection += $obj 
}#ForEach

$collection | Sort-Object Date | export-csv .\updates.csv -force

UCS on Brian Hedlund blog

Cisco UCS Networking videos (in HD), Updated & Improved!: "Cisco UCS Networking videos (in HD), Updated & Improved!"

Publish your own update in WSUS!

Local Update Publisher | Download Local Update Publisher software for free at SourceForge.net: "Local Update Publisher allows system administrators to publish their own updates to Windows Server Update Services using WSUS local publishing."