Monthly Archives: October 2014

Cleaning up Management Pack XML after SCSM Authoring Tool

For those of you working with System Center Service Manager (SCSM) and have created or edited forms in the Authoring Tool have probably noticed that Management Pack can easily become a couple of hundred rows! And that’s just the inside the <Forms> node!

This is happening due to the fact that the Authoring Tool is basically writing 3 lines of XML for every change you make. This includes changing values, moving controls etc.

There’s also some rumors that the excess amount of rows causes performance issues when loading the form in SCSM. It sounds reasonable to me, but I haven’t personally done any testing in this matter.

But fear not! The below script will remove the unnecessary XML!

I’ve included functionality for piping several XML-files, ie.

Get-ChildItem *.xml | Invoke-SCSMAuthoringToolCleanup

You can define where to save the processed XML with the parameter -OutputPath. If omitting this parameter the script will overwrite the existing Management Pack.

If you want the XML object as output for further processing, use the parameter -Passthru.

If you’re using fixed position and control sizes (which you shouldn’t!) you can omit processing of these nodes by setting the parameters -ProcessResize and -ProcessMove to $false.

You can download the script from TechNet Gallery at:
https://gallery.technet.microsoft.com/SCSM-Form-Customization-8ebe8dd7

Workaround for SMA Runbook build failure

Building a robust master SMA Runbook for your automation solutions will have a high chance of ending up with at least a couple of hundreds of lines of code (and magic!). This runbook will most likely consist of runbook nesting, modular workflows, error-handling and fault tolerance which can make things quite complex. Even for the Powershell Engine itself..

One master Runbook I authored ran into a Workflow compilation error when executing the runbook. This because of the sandboxing technology used in SMA and the error appeared because the sandboxed instance could not find the required assemblies.

The workaround is simple;

Identify and find the missing assemblies, which I did at:

C:\WINDOWS\Microsoft.NET\assembly\GAC_MSIL\System.Management.Automation\v4.0_3.0.0.0__31bf3856ad364e35\System.Management.Automation.dll
C:\WINDOWS\Microsoft.NET\assembly\GAC_MSIL\Microsoft.PowerShell.Commands.Utility\v4.0_3.0.0.0__31bf3856ad364e35\Microsoft.PowerShell.Commands.Utility.dll

And copy them to on all SMA Runbook Workers:

%windir%\System32\WindowsPowershell\v1.0

 

Below is the complete error message found in the Event Log on the SMA Runbook Worker:


Build started 2014-10-16 13:06:31.
__________________________________________________
Project "C:\Users\<SMARunbookWorkerAccount>\AppData\Local\Temp\PSWorkflowCompilation\Workflow_f8de811dc1ff4612b48fe9cc0c69d546\Project\RuntimeProject.csproj" (default targets):

Target GetReferenceAssemblyPaths:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(983,5): warning MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.
Done building target "GetReferenceAssemblyPaths" in project "RuntimeProject.csproj".
Target PrepareForBuild:
Creating directory "bin\Release\".
Creating directory "obj\Release\".
Target ResolveAssemblyReferences:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3106: Assembly strong name "C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell.Commands.Utility.dll" is either a path which could not be found or it is a full assembly name which is badly formed. If it is a full assembly name it may contain characters that need to be escaped with backslash(\). Those characters are Equals(=), Comma(,), Quote("), Apostrophe('), Backslash(\).
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3106: Assembly strong name "C:\Windows\System32\WindowsPowerShell\v1.0\System.Management.Automation.dll" is either a path which could not be found or it is a full assembly name which is badly formed. If it is a full assembly name it may contain characters that need to be escaped with backslash(\). Those characters are Equals(=), Comma(,), Quote("), Apostrophe('), Backslash(\).
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3106: Assembly strong name "C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell.Commands.Utility.dll" is either a path which could not be found or it is a full assembly name which is badly formed. If it is a full assembly name it may contain characters that need to be escaped with backslash(\). Those characters are Equals(=), Comma(,), Quote("), Apostrophe('), Backslash(\).
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3106: Assembly strong name "C:\Windows\System32\WindowsPowerShell\v1.0\System.Management.Automation.dll" is either a path which could not be found or it is a full assembly name which is badly formed. If it is a full assembly name it may contain characters that need to be escaped with backslash(\). Those characters are Equals(=), Comma(,), Quote("), Apostrophe('), Backslash(\).
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "mscorlib", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "System.Data", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
Done building target "ResolveAssemblyReferences" in project "RuntimeProject.csproj".
Target XamlMarkupCompilePass1:
C:\Users\<SMARunbookWorkerAccount>\AppData\Local\Temp\PSWorkflowCompilation\Workflow_f8de811dc1ff4612b48fe9cc0c69d546\Project\ho5coutk.gts.xaml : error XC1014: Assembly 'Microsoft.PowerShell.Commands.Utility, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' can not be resolved. Please add a reference to this assembly in the project that is being built.
C:\Users\<SMARunbookWorkerAccount>\AppData\Local\Temp\PSWorkflowCompilation\Workflow_f8de811dc1ff4612b48fe9cc0c69d546\Project\onhtvslm.qxx.xaml : error XC1014: Assembly 'Microsoft.PowerShell.Commands.Utility, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' can not be resolved. Please add a reference to this assembly in the project that is being built.
C:\Users\<SMARunbookWorkerAccount>\AppData\Local\Temp\PSWorkflowCompilation\Workflow_f8de811dc1ff4612b48fe9cc0c69d546\Project\rl5vmykt.eca.xaml : error XC1014: Assembly 'Microsoft.PowerShell.Commands.Utility, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' can not be resolved. Please add a reference to this assembly in the project that is being built.
Done building target "XamlMarkupCompilePass1" in project "RuntimeProject.csproj" -- FAILED.

Done building project "RuntimeProject.csproj" -- FAILED.

Build FAILED.

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(983,5): warning MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3106: Assembly strong name "C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell.Commands.Utility.dll" is either a path which could not be found or it is a full assembly name which is badly formed. If it is a full assembly name it may contain characters that need to be escaped with backslash(\). Those characters are Equals(=), Comma(,), Quote("), Apostrophe('), Backslash(\).
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3106: Assembly strong name "C:\Windows\System32\WindowsPowerShell\v1.0\System.Management.Automation.dll" is either a path which could not be found or it is a full assembly name which is badly formed. If it is a full assembly name it may contain characters that need to be escaped with backslash(\). Those characters are Equals(=), Comma(,), Quote("), Apostrophe('), Backslash(\).
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3106: Assembly strong name "C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell.Commands.Utility.dll" is either a path which could not be found or it is a full assembly name which is badly formed. If it is a full assembly name it may contain characters that need to be escaped with backslash(\). Those characters are Equals(=), Comma(,), Quote("), Apostrophe('), Backslash(\).
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3106: Assembly strong name "C:\Windows\System32\WindowsPowerShell\v1.0\System.Management.Automation.dll" is either a path which could not be found or it is a full assembly name which is badly formed. If it is a full assembly name it may contain characters that need to be escaped with backslash(\). Those characters are Equals(=), Comma(,), Quote("), Apostrophe('), Backslash(\).
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "mscorlib", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "System.Data", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
C:\Users\<SMARunbookWorkerAccount>\AppData\Local\Temp\PSWorkflowCompilation\Workflow_f8de811dc1ff4612b48fe9cc0c69d546\Project\ho5coutk.gts.xaml : error XC1014: Assembly 'Microsoft.PowerShell.Commands.Utility, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' can not be resolved. Please add a reference to this assembly in the project that is being built.
C:\Users\<SMARunbookWorkerAccount>\AppData\Local\Temp\PSWorkflowCompilation\Workflow_f8de811dc1ff4612b48fe9cc0c69d546\Project\onhtvslm.qxx.xaml : error XC1014: Assembly 'Microsoft.PowerShell.Commands.Utility, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' can not be resolved. Please add a reference to this assembly in the project that is being built.
C:\Users\<SMARunbookWorkerAccount>\AppData\Local\Temp\PSWorkflowCompilation\Workflow_f8de811dc1ff4612b48fe9cc0c69d546\Project\rl5vmykt.eca.xaml : error XC1014: Assembly 'Microsoft.PowerShell.Commands.Utility, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' can not be resolved. Please add a reference to this assembly in the project that is being built.
7 Warning(s)
3 Error(s)

Time Elapsed 00:00:03.05

Download Microsoft vNext Technical Preview with Powershell!

UPDATE: Added Windows 10 Enterprise and SQL Server 2014.

Microsoft just released the Technical Preview for Windows Server vNext and System Center vNext!

Release Notes for Windows Server: http://technet.microsoft.com/library/dn765470.aspx
What’s New for Windows Server: http://technet.microsoft.com/library/dn765472.aspx

Release Notes for System Center: http://technet.microsoft.com/en-us/library/dn806369.aspx

Aaaaaaaaaaand, let me present the download script!

Use the parameter -Path to specify the download folder.
Use the parameter -WithProgress if you want to see the progress of the download.

withprogress