Add server to WSUS

Create a .reg file with this: (this is for 24.00)

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINESOFTWAREPoliciesMicrosoftwindowsWindowsUpdate]
“WUServer”=”http://wsus.xxx.dk”
“WUStatusServer”=”http://wsus.xxx.dk”

[HKEY_LOCAL_MACHINESOFTWAREPoliciesMicrosoftwindowsWindowsUpdateAU]
“NoAutoUpdate”=dword:00000000
“AUOptions”=dword:00000004
“ScheduledInstallDay”=dword:00000000
“ScheduledInstallTime”=dword:00000000
“UseWUServer”=dword:00000001
“RescheduleWaitTimeEnabled”=dword:00000001
“RescheduleWaitTime”=dword:00000005
“DetectionFrequencyEnabled”=dword:00000001
“DetectionFrequency”=dword:00000001
“AutoInstallMinorUpdates”=dword:00000001
“RebootWarningTimeoutEnabled”=dword:00000001
“RebootWarningTimeout”=dword:00000005
“RebootRelaunchTimeoutEnabled”=dword:00000001
“RebootRelaunchTimeout”=dword:00000005
“NoAUShutdownOption”=dword:00000001

Then to get Windows to accept the changes type this in a CMD:

net stop “Windows Update”

call wuauclt /resetauthorization /detectnow”

Last reboot time

Make a vbs file with this and run it :

strComputer = “.”
set objWMIDateTime = CreateObject(“WbemScripting.SWbemDateTime”)
set objWMI = GetObject(“winmgmts:” & strComputer & “rootcimv2”)
set colOS = objWMI.InstancesOf(“Win32_OperatingSystem”)
for each objOS in colOS
objWMIDateTime.Value = objOS.LastBootUpTime
Wscript.Echo “Reboot time: ” & objWMIDateTime.GetVarDate
next

Install SNMP with script

To install SNTP with a script create 2 files:

  • Start.bat
  • snmp.txt

In start.bat put :

copy SNMP.txt %SYSTEMDRIVE%

%windir%system32sysocmgr.exe /i:%windir%infsysoc.inf /u:%SYSTEMDRIVE%SNMP.txt /r

in snmp.txt put :

[NetOptionalComponents]
SNMP = 1

After this run start.bat on the machine

Export all mailboxes

Copy this to a .ps1 and run it :

######
#    Choose option yes/no
######

$title = “Export mailboxes from Exchange 2010 SP1+”
$message = “Do you want to Export All Mailboxes?”

$yes = New-Object System.Management.Automation.Host.ChoiceDescription “&Yes”, “Export all Mailboxes on the Exchange server.”

$no = New-Object System.Management.Automation.Host.ChoiceDescription “&No”, “Don’t want to Export all Mailboxes.”

$options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)

$result = $host.ui.PromptForChoice($title, $message, $options, 0)

if ($result -eq “0”) {

$script:SharedPath = Read-Host “Enter UNC path for pst-folders”

######
#    Test if sharedpath exists
######

$Path = $script:SharedPath

if (Test-Path $Path) {
Write-Host “SharedFolder OK…!” -ForeGroundColor Green
}

else {
Write-Host “SharedFolder doesn’t exists…! ” -ForeGroundColor Red
break
}

######
#    Export Mailboxes
######
$colitems = Get-mailbox
Foreach($objitem in $colitems) {

Write-host “Start Exporting mailboxes” -ForeGroundColor Green

New-MailboxExportRequest -Mailbox $objItem -FilePath “$Path$objitem.pst”;
}
}

if ($result -eq “1”) {

clear
Write-host “Stop Exporting mailboxes” -ForeGroundColor Red
}

Activate Windows

To easy activate Windows you can make a bat file with this (you only have to put in the keys)

@echo off

REG QUERY “HKLMSOFTWAREMicrosoftWindows NTCurrentVersion” /v “EditionID” | FINDSTR /I SERVERSTANDARD
IF NOT ERRORLEVEL 1 SET PROD=SERVERSTANDARD
REG QUERY “HKLMSOFTWAREMicrosoftWindows NTCurrentVersion” /v “EditionID” | FINDSTR /I SERVERENTERPRISE
IF NOT ERRORLEVEL 1 SET PROD=SERVERENTERPRISE
REG QUERY “HKLMSOFTWAREMicrosoftWindows NTCurrentVersion” /v “ProductName” | findstr /I DATACENTER
IF NOT ERRORLEVEL 1 SET PROD=DATACENTER
REG QUERY “HKLMSOFTWAREMicrosoftWindows NTCurrentVersion” /v “ProductName” | findstr /I “Web”
IF NOT ERRORLEVEL 1 SET PROD=WEBSERVER

REG QUERY “HKLMSOFTWAREMicrosoftWindows NTCurrentVersion” /v “ProductName” | findstr /I R2
IF NOT ERRORLEVEL 1 ( SET PROD=%PROD%R2) else ( SET PROD=%PROD%R0)

REG QUERY “HKLMSOFTWAREMicrosoftWindows NTCurrentVersion” /v “ProductName” | findstr /I 2008
IF NOT ERRORLEVEL 1 SET PROD=%PROD%2008
REG QUERY “HKLMSOFTWAREMicrosoftWindows NTCurrentVersion” /v “ProductName” | findstr /I “2012”
IF NOT ERRORLEVEL 1 SET PROD=%PROD%2012
REG QUERY “HKLMSOFTWAREMicrosoftWindows NTCurrentVersion” /v “ProductName” | findstr /I “7”
IF NOT ERRORLEVEL 1 SET PROD=7

IF %PROD%==SERVERSTANDARDR02008 SET PIDKEY=
IF %PROD%==SERVERENTERPRISER02008 SET PIDKEY=
IF %PROD%==DATACENTERR02008 SET PIDKEY=
IF %PROD%==WEBSERVERR02008 SET PIDKEY=
IF %PROD%==SERVERSTANDARDR22008 SET PIDKEY=
IF %PROD%==SERVERENTERPRISER22008 SET PIDKEY=
IF %PROD%==DATACENTERR22008 SET PIDKEY=XBWXK-
IF %PROD%==WEBSERVERR22008 SET PIDKEY=
IF %PROD%==SERVERSTANDARDR02012 SET PIDKEY=
IF %PROD%==DATACENTERR02012 SET PIDKEY=
IF %PROD%==7 SET PIDKEY=

cscript %windir%System32slmgr.vbs -ipk %PIDKEY%
cscript %windir%System32slmgr.vbs -ato

XEN add more RAM

Log on the XEN server and find the uuid on the virtual machine

-xe vm-list name-label=XXXXXXXX
uuid ( RO)           : 74219c66-6b57-0da2-3062-b4d8bcea50be
name-label ( RW): XXXXXX

Then you can se how it’s set up now :

-xe vm-list name-label=XXXXXXXX params=all

memory-overhead ( RO): 90177536

memory-static-max ( RW): 10737418240

memory-dynamic-max ( RW): 10737418240

memory-dynamic-min ( RW): 10737418240

memory-static-min ( RW): 1073741824

The you can set the new values:

xe vm-param-set uuid=74219c66-6b57-0da2-3062-b4d8bcea50be memory-static-min=14GiB
xe vm-param-set uuid=74219c66-6b57-0da2-3062-b4d8bcea50be memory-dynamic-min=14GiB
xe vm-param-set uuid=74219c66-6b57-0da2-3062-b4d8bcea50be memory-dynamic-max=14GiB
xe vm-param-set uuid=74219c66-6b57-0da2-3062-b4d8bcea50be memory-static-max=14GiB

Get SQL version

SELECT ‘SQL Server ‘
+ CAST(SERVERPROPERTY(‘productversion’) AS VARCHAR) + ‘ – ‘
+ CAST(SERVERPROPERTY(‘productlevel’) AS VARCHAR) + ‘ (‘
+ CAST(SERVERPROPERTY(‘edition’) AS VARCHAR) + ‘)’

Exchange 2007

Add permissins to use

Add-MailboxPermission -identity TestA -User TestB -AccessRights FullAccess

Export all mailboxes to PST files:

Get-Mailbox -OrganizationalUnit SBSUsers | Export-Mailbox -PSTFolderPath D:PSTFiles
Get-Mailbox -Database ‘XXXX.localMailbox Database’ | Export-Mailbox -PSTFolderPath Z:

Export one mailboxe to PST files:

Get-Mailbox –Identity user1@user1.dk | Export-Mailbox -PSTFolderPath D:PSTFiles

Size on mailboxes:

Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | ft DisplayName,@{label=”TotalItemSize(MB)”;expression={$_.TotalItemSize.Value.ToMB()}},ItemCount