lørdag den 30. april 2011

New-CrmOrganization The Deployment Service cannot process the request because one or more validation checks failed.

I’m playing around with scripting and implementing CRM 2011 into my provisioning and kept banging my head trying to figure out why the !”¤# I constantly would get

New-CrmOrganization : The Deployment Service cannot process the request because one or more validation checks failed.

I could create new Organization fine in the Deployment Manager MMC, so I smacked together a VB console app calling the deployment web service and got same result. No luck.

I gave up for a while and spend some time reading up and creating the environment for running ADFS 2.0 for Claims-based Authentication. ( I can recommend reading the MS guide and this YouTube video is a MUST! )

So after struggling abet with certificates a went back to the original problem. I must admit I have NO idea why, but after I managed to get ADFS working seemingly internally and externally, suddenly both PowerShell and calling the deployment web service directly worked again. So I guess the lesson learned is. Get that up and running BEFORE trying to script the rest Winking smile

onsdag den 27. april 2011

Remote Desktop RemoteAPP not running logon scripts

This one was giving my some headaches. Sometimes people would see there network drives, and sometimes people could only see there home drive when launching applications directely instead of starting a desktop. Found tons of people who had “smart” hacks messing with RDP properties and runonce keys, but not anything I really liked. Was talking with a friend about it and he mentioned trying to use USRLOGON.CMD to just call the normal logon script. That didn’t quite work for me, but creating C:\Windows\System32\usrlogn1.cmd and then copy’ing the logon script localy and executing it, works seamlessly for me.

C:\Windows\System32\usrlogn1.cmd containing
xcopy /S /Y \\domain.fqdn\NETLOGON %temp%
C:\Windows\System32\cscript.exe %temp%\logon.vbs

onsdag den 13. april 2011

Getting list of XenApp hotfixes, installing hotfix’es unattended from powershell

Searched high and low for this, and couldn’t find anything, so here is my version.

# Regiser Addins if missing
$snapin = Get-PSSnapin | where {$_.name -eq 'Citrix.Common.Commands'}
if($snapin -eq $null){ Add-PSSnapin Citrix.Common.Commands }
$snapin = Get-PSSnapin | where {$_.name -eq 'Citrix.XenApp.Commands'}
if($snapin -eq $null){ Add-PSSnapin Citrix.XenApp.Commands }

function installXenappHotfix([string]$HotfixName, [string]$hotfixpath ){
# Get current computername and XenServer object
$computername = get-content env:computername

$isInstalled = $false;
foreach($hotfix in (Get-XAServerHotFix -ServerName $computername)){
if($hotfix.HotfixName -eq $HotfixName){ $isInstalled = $true; }
}
if($isInstalled -eq $false){
Write
-Host ('Missing ' + $HotfixName)
$exitcode = (Start-Process -FilePath "msiexec.exe" -ArgumentList "/qb /passive /norestart /p `"$hotfixpath`"" -Wait -Passthru).ExitCode
if($exitcode -eq 3010){
$exitcode = 1604
Write
-Host 'Restart needed, so restarting. doh!'
restart
-computer -force -throttlelimit 10; exit $exitcode
exit
$exitcode
}
if($exitcode -ne 0){
Write
-Host ('Unknown exitcode: ' + $exitcode)
exit
$exitcode
}
}
else { Write-Host ($HotfixName + ' ok') }
}

installXenappHotfix 'XA600W2K8R2X64001' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64001.msp'
installXenappHotfix 'XA600W2K8R2X64002' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64002.msp'
installXenappHotfix 'XA600W2K8R2X64003' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64003.msp'
installXenappHotfix 'XA600W2K8R2X64004' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64004.msp'
installXenappHotfix 'XA600W2K8R2X64006' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64006.msp'
installXenappHotfix 'XA600W2K8R2X64007' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64007.msp'
installXenappHotfix 'XA600W2K8R2X64008' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64008.msp'
installXenappHotfix 'XA600W2K8R2X64009' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64009.msp'
installXenappHotfix 'XA600W2K8R2X64010' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64010.msp'
installXenappHotfix 'XA600W2K8R2X64011' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64011.msp'
installXenappHotfix 'XA600W2K8R2X64012' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64012.msp'
installXenappHotfix 'XA600W2K8R2X64013' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64013.msp'
installXenappHotfix 'XA600W2K8R2X64015' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64015.msp'
installXenappHotfix 'XA600W2K8R2X64016' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64016.msp'
installXenappHotfix 'XA600W2K8R2X64017' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64017.msp'
installXenappHotfix 'XA600W2K8R2X64018' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64018.msp'
installXenappHotfix 'XA600W2K8R2X64019' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64019.msp'
installXenappHotfix 'XA600W2K8R2X64020' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64020.msp'
installXenappHotfix 'XA600W2K8R2X64021' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64021.msp'
installXenappHotfix 'XA600W2K8R2X64023' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64023.msp'
installXenappHotfix 'XA600W2K8R2X64026' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64026.msp'
installXenappHotfix 'XA600W2K8R2X64027' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64027.msp'
installXenappHotfix 'XA600W2K8R2X64028' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64028.msp'
installXenappHotfix 'XA600W2K8R2X64029' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64029.msp'
installXenappHotfix 'XA600W2K8R2X64030' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64030.msp'
installXenappHotfix 'XA600W2K8R2X64031' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64031.msp'
installXenappHotfix 'XA600W2K8R2X64033' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64033.msp'
installXenappHotfix 'XA600W2K8R2X64035' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64035.msp'
installXenappHotfix 'XA600W2K8R2X64036' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64036.msp'
installXenappHotfix 'XA600W2K8R2X64037' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64037.msp'
installXenappHotfix 'XA600W2K8R2X64038' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64038.msp'
installXenappHotfix 'XA600W2K8R2X64039' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64039.msp'
installXenappHotfix 'XA600W2K8R2X64041' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64041.msp'

torsdag den 7. april 2011

PSCmdlet with several ParameterSets containing same Parameter

One thing I kept running into when creating CmdLet’s was when I want to give the user the ability to pass in several parameters as both object or by ID. Troubleshooting passing in this parameters can be a bit annoying so here's a few pointers.

Imagine you have a PSCmdlet that needs a customer and a plan. lets call it New-CustomerService and the parameters Customer or CustomerID and ServicePlan or ServicePlanID this will give a total of 4 different ways of passing parameters hence 4 ParameterSetName names.

 

Private _Customer As New List(Of wsCloudAPI.extCustomer)
<Parameter(Position:=0, Mandatory:=True, ValueFromPipeline:=True, ValueFromPipelineByPropertyName:=True, ParameterSetName:="set1")> _
<Parameter(Position:=0, Mandatory:=True, ValueFromPipeline:=True, ValueFromPipelineByPropertyName:=True, ParameterSetName:="set2")> _
<ValidateNotNullOrEmpty()> _
Public Property Customer() As List(Of wsCloudAPI.extCustomer)
    Get
        Return _Customer
    End Get
    Set(ByVal value As List(Of wsCloudAPI.extCustomer))
        _Customer = value
        For Each o In _Customer
            _CustomerID.Add(o.CustomerID)
        Next
    End Set
End Property

Private _CustomerID As New List(Of Integer)
<Parameter(Position:=0, Mandatory:=True, ValueFromPipeline:=True, ValueFromPipelineByPropertyName:=True, ParameterSetName:="set3")> _
<Parameter(Position:=0, Mandatory:=True, ValueFromPipeline:=True, ValueFromPipelineByPropertyName:=True, ParameterSetName:="set4")> _
<ValidateNotNullOrEmpty()> _
Public Property CustomerID() As List(Of Integer)
    Get
        Return _CustomerID
    End Get
    Set(ByVal value As List(Of Integer))
        _CustomerID = value
    End Set
End Property

Private _ServicePlan As New List(Of wsCloudAPI.extServicePlan)
<Parameter(Position:=1, Mandatory:=True, ValueFromPipeline:=True, ValueFromPipelineByPropertyName:=True, ParameterSetName:="set1")> _
<Parameter(Position:=1, Mandatory:=True, ValueFromPipeline:=True, ValueFromPipelineByPropertyName:=True, ParameterSetName:="set3")> _
<ValidateNotNullOrEmpty()> _
Public Property ServicePlan() As List(Of wsCloudAPI.extServicePlan)
    Get
        Return _ServicePlan
    End Get
    Set(ByVal value As List(Of wsCloudAPI.extServicePlan))
        _ServicePlan = value
        For Each o In _ServicePlan
            _PlanID.Add(o.PlanID)
        Next
    End Set
End Property

Private _PlanID As New List(Of Integer)
<Parameter(Position:=1, Mandatory:=True, ValueFromPipeline:=True, ValueFromPipelineByPropertyName:=True, ParameterSetName:="set2")> _
<Parameter(Position:=1, Mandatory:=True, ValueFromPipeline:=True, ValueFromPipelineByPropertyName:=True, ParameterSetName:="set4")> _
<ValidateNotNullOrEmpty()> _
Public Property PlanID() As List(Of Integer)
    Get
        Return _PlanID
    End Get
    Set(ByVal value As List(Of Integer))
        _PlanID = value
    End Set
End Property

Testing if this work, can then be done with

trace-command parameterbinding -pshost { New-CustomerService $customer -ServicePlan $plan }

But there is another cute way of checking the different parameter sets


(get-command New-CustomerService).ParameterSets | foreach {
$ps = $_.name
$_.Parameters | Select @{n="ParameterName";e={$_.name}},@{n="Mandatory";e={$_.IsMandatory}},@{n="Position";e={$_.Position}},@{n="HelpMessage";e={$_.HelpMessage}},@{n="ParameterSet";e={$ps}} | Format-Table
}

mandag den 4. april 2011

SCOM 2007 R2–Clearing Console Cache

Note to self.
Go to C:\Users\<Username>\AppData\Local\Microsoft\Microsoft.Mom.UI.Console and delete momcache.mdb