The Problem that Joseph is having will appear on any System outside the USA! Microsoft only handled the culture for en-US, on any other System culture you get the error like JosephFenly posted.
As each powershell command is a new thread, you cannot simply set the current culture to en-US and have done. Fortunately the solution is relatively easy...
Encompas the code of the function itself in the following brackets:
&{
# Set thread current culture for Excel
[threading.thread]::CurrentThread.CurrentCulture = 'en-US'
# Code goes here
}
Therefore the function should look like this:
function Add-SRComment {
param (
[parameter(Mandatory=$true,Position=0)][Alias('SRObject')]$pSRObject,
[parameter(Mandatory=$true,Position=1)][Alias('Comment')][String]$pComment,
[parameter(Mandatory=$true,Position=2)][Alias('EnteredBy')][String]$pEnteredBy
)
&{
# Set thread current culture
[threading.thread]::CurrentThread.CurrentCulture = 'en-US'
$NewGUID = ([guid]::NewGuid()).ToString()
$Projection = @{__CLASS = "System.WorkItem.ServiceRequest";
__SEED = $pSRObject;
AnalystCommentLog = @{__CLASS = "System.WorkItem.TroubleTicket.AnalystCommentLog";
__OBJECT = @{Id = $NewGUID;
DisplayName = $NewGUID;
Comment = $pComment;
EnteredBy = $pEnteredBy;
EnteredDate = (Get-Date).ToUniversalTime();
IsPrivate = $false
}
}
}
New-SCSMObjectProjection -Type "System.WorkItem.ServiceRequestProjection" -Projection $Projection
}
}
-
Edited by
Sinclair A B
Tuesday, April 14, 2015 1:37 PM
-
Proposed as answer by
Sinclair A B
Tuesday, April 14, 2015 2:07 PM