I recently got the chalange to replace the printserver at my job and to create a new printserver environment. So while we are working on getting Res Workspace Manager life in action the next step would be breaking down the current printserver and replace it with 4 printservers each hosting under 400 printers. In Res Workspace manager you can make a variable in 'Actions by Type' > Environment Variables'. Now here I created a variable for the new printserver that points to the current printserver. The trick is when you are ready to run production with the new printserver you can simply switch the name of the Value and the new printserver will be online in Res Workspace Manager. 

 

So far step 1, I now had to do a search and replace action in  the exported building block containing all the published printers within RES WM. After a search on the internet. I found of course, a powershell script and I started with testing and altering a few things, then I stumpled on the blog of Tangodude. The first script I tested changed all info my csv file urhmmm yeah not what i wanted. Btw did i mentioned I created a csv file using Excell to create my search and replace file. This csv file contains the following:

OldValue,NewValue
\\OLDPRINTSRV\\PRINTER,\NEWPRINTSRV\PRINTER

Look at the NewValue, if you put \\ like the OldValue you will end up with \\\NEWPRINTSRV\Printer in your XML file.

I created a buildingblock of all my printers hosted in RES WM and a replace CSV(TransformList.csv) containing 1200 printers with 4 variables because I want to split up my printserver environment.

Here is the script that I used:

Param (   
[String]$List = "TransformList.csv",   
[String]$Files = ".\*.*")
$ReplacementList = Import-Csv $List;
Get-ChildItem $Files |
ForEach-Object {
   $Content = Get-Content -Path $_.FullName;   
 foreach ($ReplacementItem in $ReplacementList)   
 {       
  $Content = $Content -IReplace $ReplacementItem.OldValue, $ReplacementItem.NewValue;   
 }   
Set-Content -Path $_.FullName -Value $Content}

Here is the cli line I used in powershell

PS C:\temp\Compare> .\replaceservers.ps1 -list ".\TransFormList.csv" -files ".\printersResWorkspace.XML"

Now I got a changed file 'printersResWorkspace.XML with 4 variables inside it pointing to 4 different printservers. Within RES Workspace Manager you can now easy import the building block. When you import the building block mind that you choose 'Orignal GUIDs (overwrites existing objects)' otherwhise all your links in the object (printer) will be broken.

 

 

After you got the new printserver in production you can easaly change the variables to the correct printservers.

Scriptsource blog http://tangodude.wordpress.com/category/powershell/


Note: Test the import on a testdatabase for Res Workspace Manager before using it in production and always! make sure you have a backup of your printer environment. Better safe then sorry :)