Tag Archives: Driver installation

Add Printer Script Unique Print Drivers

For an automated installation it was necessary to have an up to date list of the printer drivers. As print manufactorers occassionally add a dozen printer drivers into one setup we wanted to have a script that connects to all on duty print servers. I used the function Add-PrinterDriver for this cause. In the RES Automation Manager script there was some code necessary to first add a feature if it wasn’t present:

Import-Module ServerManager
$RSATADPowerShell = Get-WindowsFeature -Name "RSAT-AD-PowerShell"
If ($RSATADPowerShell.Installed -match "False"){
Add-WindowsFeature RSAT-AD-PowerShell}

Then I added the function in another script:

Import-Module ActiveDirectory
#Functie Add-PrinterDriver
function Add-PrinterDriver { 
 [CmdletBinding()] 
         Param( 
              [Parameter(Mandatory=$true)] 
              [string] $PrintServer, 
              [switch] $Clean 
             ) 

#Collecting all shared printer objects from the specified print server 
$allprinters = @(Get-WmiObject win32_printer -ComputerName $PrintServer -Filter 'shared=true') 
#Defining all unique printer drivers from the specified print server 
$drivers = @($allprinters | Select-Object drivername -Unique) 
#Defining a collection containing the first printer object using a unique printer driver 
$printers = @() 
foreach ($item in $drivers){ 
$printers += @($allprinters | Where-Object {$_.drivername -eq $item.drivername})[0] 
} 

#Collecting locally installed drivers 
$localdrivers = @() 
foreach ($driver in (Get-WmiObject Win32_PrinterDriver)){ 
$localdrivers += @(($driver.name -split ",")[0]) 
} 

#Initializing the CurrentPrinter variable for use with Write-Progress 
$CurrentPrinter = 1 

#Looping through the printer objects collection, installing those who are not already installed on the local computer 
foreach ($printer in $printers) { 

Write-Progress -Activity "Installing printers..." -Status "Current printer: $($printer.name)" -Id 1 -PercentComplete (($CurrentPrinter/$printers.count) * 100) 

#Create hash-table for output object 
$outputobject = @{} 
$outputobject.drivername = $printer.drivername 

$locallyinstalled = $localdrivers | Where-Object {$_ -eq $printer.drivername} 
if (-not $locallyinstalled) { 
Write-Verbose "$($printer.drivername) is not installed locally" 
$AddPrinterConnection = Invoke-WmiMethod -Path Win32_Printer -Name AddPrinterConnection -ArgumentList ([string]::Concat('\', $printer.__SERVER, '', $printer.ShareName)) -EnableAllPrivileges 
$outputobject.returncode = $AddPrinterConnection.ReturnValue 
} 
else 
{ 
Write-Verbose "$($printer.drivername) is already installed locally" 
$outputobject.returncode = "Already installed" 
} 

#Create a new object for each driver, based on the outputobject hash-table 
New-Object -TypeName PSObject -Property $outputobject 

$CurrentPrinter ++ 

} 

#Deletes all printer connections for the current user 
if ($clean) { 
$printers = Get-WmiObject Win32_Printer -EnableAllPrivileges -Filter network=true 
if ($printers) { 
foreach ($printer in $printers) { 
$printer.Delete() 
} 
} 
} 
}

$OS = (Get-WmiObject Win32_OperatingSystem).Caption.replace("Microsoft ","").Replace("Standard ","Standard").Replace("Enterprise ","Enterprise").Replace("Datacenter ","Datacenter")
$ADPrintservers = Get-ADComputer -Filter * -Property * |Where {$_.name -like "PR*"} | select DNSHostName,OperatingSystem
$Pingable =@()
foreach ($computer in $ADPrintservers){
if (Test-Connection $Computer.DNSHostName -quiet) { $Pingable += $Computer}}
foreach ($Computer in $Pingable){
If ($OS -contains $Computer.OperatingSystem){
Add-PrinterDriver -Printserver $Computer.DNSHostName}}

The script above enumerates all servers starting with PR*. Next this script test whether the server is pingable or not. You could enter credentials if you disabled pinging to the Test-Connection command. Next it validates if the server has the same OS as the print server. Some print servers are around for the 32 bit environment. You can also add a filter for that. At the end it deletes the space that is somehow added to the replace part of OS variable.  The bare function is like this:

function Add-PrinterDriver { 
 [CmdletBinding()] 
         Param( 
              [Parameter(Mandatory=$true)] 
              [string] $PrintServer, 
              [switch] $Clean 
             ) 

#Collecting all shared printer objects from the specified print server 
$allprinters = @(Get-WmiObject win32_printer -ComputerName $PrintServer -Filter 'shared=true') 
#Defining all unique printer drivers from the specified print server 
$drivers = @($allprinters | Select-Object drivername -Unique) 
#Defining a collection containing the first printer object using a unique printer driver 
$printers = @() 
foreach ($item in $drivers){ 
$printers += @($allprinters | Where-Object {$_.drivername -eq $item.drivername})[0] 
} 

#Collecting locally installed drivers 
$localdrivers = @() 
foreach ($driver in (Get-WmiObject Win32_PrinterDriver)){ 
$localdrivers += @(($driver.name -split ",")[0]) 
} 

#Initializing the CurrentPrinter variable for use with Write-Progress 
$CurrentPrinter = 1 

#Looping through the printer objects collection, installing those who are not already installed on the local computer 
foreach ($printer in $printers) { 

Write-Progress -Activity "Installing printers..." -Status "Current printer: $($printer.name)" -Id 1 -PercentComplete (($CurrentPrinter/$printers.count) * 100) 

#Create hash-table for output object 
$outputobject = @{} 
$outputobject.drivername = $printer.drivername 

$locallyinstalled = $localdrivers | Where-Object {$_ -eq $printer.drivername} 
if (-not $locallyinstalled) { 
Write-Verbose "$($printer.drivername) is not installed locally" 
$AddPrinterConnection = Invoke-WmiMethod -Path Win32_Printer -Name AddPrinterConnection -ArgumentList ([string]::Concat('\', $printer.__SERVER, '', $printer.ShareName)) -EnableAllPrivileges 
$outputobject.returncode = $AddPrinterConnection.ReturnValue 
} 
else 
{ 
Write-Verbose "$($printer.drivername) is already installed locally" 
$outputobject.returncode = "Already installed" 
} 

#Create a new object for each driver, based on the outputobject hash-table 
New-Object -TypeName PSObject -Property $outputobject 

$CurrentPrinter ++ 

} 

#Deletes all printer connections for the current user 
if ($clean) { 
$printers = Get-WmiObject Win32_Printer -EnableAllPrivileges -Filter network=true 
if ($printers) { 
foreach ($printer in $printers) { 
$printer.Delete() 
} 
} 
} 
}

This function lets powershell connect to the printserver. It does a query on all shared printers. Then it sorts the results to unique values. At last it connects to that printer which causes the driver to be installed. There is a group policy necessary for this to work. The following policy settings are mandatory:

PointAndPrintRestrictions

 

This is a computer policy located at Computer Configuration –> Windows Settings –> Printers –> Point and Print Restrictions

Recently i extended my RAID 5 array by replacing one-by-one hdd’s with bigger ones and waiting for each to rebuild.

All the instructions are executed on a HP DL360 G6 with an SmartArray P410i controller with only one logicaldisk.

It is highly recommended that you backup all your VM’s before executing a single command – everything worked fine for me but one error in a command could leas to a complete data loss of everything!

To see the rebuilding status, HP has a tool called hpacucli which allows you to control the array and see the status of it out of the ESXi console.

First you have to install HP’s ESXi5 Offline Utilities right from here

Upload it to your datastore, login to your ESXi5 server and execute

esxcli software vib install -d/path/to/hp-HPUtil-esxi5.0-bundle-1.1-38.zip

Now you can see the array rebuild with

/opt/hp/hpacucli/bin/hpacucli controller slot=0 show config

** Warning: Add a new hard disk ONLY if ALL harddisks show “OK” **
After adding all the disks without destroying the array you can now see unused space here:

/opt/hp/hpacucli/bin/hpacucli controller slot=0 array all show detail

Now let’s extend the array to use up the new space:

/opt/hp/hpacucli/bin/hpacucli controller slot=0 logicaldrive 1 modify size=max

A second call to show detail of the array should show you that the unused space is again zero, now your logicaldrive is successfully extended!

/opt/hp/hpacucli/bin/hpacucli controller slot=0 array all show detail

Now on to the datastore part. Unfortunatly it is not possible to extend or expand the datastore from within the GUI because the “VMWare extend” is for adding several sources of Partitions, NFS mounts etc. to one “big” datastore and not expanding the partition to fill up the new space we won.

First we need to find what disk we are using, as i’m have only one logical disk, this is easy for me, be sure to select the correct disk from: /vmfs/devices/disks/

let have a look at the partitioning table:

partedUtil getptbl /vmfs/devices/disks/vml.0200010000600508b1001c504c1f73b6b6947016164c4f47494341

gpt
109406 255 63 1757614684
1 64 8191 C12A7328F81F11D2BA4B00A0C93EC93B systemPartition 128
5 8224 520191 EBD0A0A2B9E5443387C068B6B72699C7 linuxNative 0
6 520224 1032191 EBD0A0A2B9E5443387C068B6B72699C7 linuxNative 0
7 1032224 1257471 9D27538040AD11DBBF97000C2911D1B8 vmkDiagnostic 0
8 1257504 1843199 EBD0A0A2B9E5443387C068B6B72699C7 linuxNative 0
2 1843200 10229759 EBD0A0A2B9E5443387C068B6B72699C7 linuxNative 0
3 10229760 860050190 AA31E02A400F11DB9590000C2911D1B8 vmfs 0

The last line is the one we are intrested in, the VMFS partition. For me it is the Partition number 3 with start-sector at 10229760 and end-sector at 860050190.

We now need to know the last sector of the Harddisk we could use up, give that a shot:

partedUtil getUsableSectors /vmfs/devices/disks/vm.0200010000600508b1001c504c1f73b6b6947016164c4f47494341

This is what i get back: 1757614650

Now i can go and extend the partition where my datastore lives in:

partedUtil resize “/vmfs/devices/disks/vml.0200010000600508b1001c504c1f73b6b6947016164c4f47494341″ 3 10229760 1757614650

Note the last 3 arguments: Partition 3, start-sector and new last-sector

After that has been done without output we will stright go and expand the Filesystem of our VMFS partition to fill it up:

vmkfstools –growfs /vmfs/devices/disks/vml.0200010000600508b1001c504c1f73b6b6947016164c4f47494341:3 /vmfs/devices/disks/vml.0200010000600508b1001c504c1f73b6b6947016164c4f47494341:3

Again, note the :3 at the end..

http://devbios.wordpress.com/2012/04/21/esxi-5-expanding-datastore-by-extending-local-array/

Algemene inrichting

Microsoft Tweaks

Wanneer Windows geïnstalleerd is wordt er in de advanced settings van de computer Write debugging Small memory dump ingesteld van 256 KB.

Configureerd het virtueel geheugen met 300 MB meer dan het werkgeheugen.

Bij de power options in het control panel moet High performance geselecteerd worden.

10 Gbit
In het VMware VMX config wordt de netwerk adapter VMXnet3 gebruikt. Deze adapter is 10 Gbit.

VMware Tools
VMware tools worden altijd geïnstalleerd op templates en handmatige geïnstalleerde servers.

Paravirtuele drivers

Bij het inrichten van een template moet de paravirtual driver floppy gemount worden worden voordat Windows wordt geinstalleerd. Tevens kan een ISO gemount worden voor de installatie. Tijdens de installatie wordt gevraagd naar het laden van Drivers. Kies daar dan de drivers die op het Floppy staat.