-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More compatible with psdscrunascredential #16
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @justacurley - thanks for the submission. There are some changes that need to be implemented, but nothing too difficult. If you have any questions, just ask! Thanks
@@ -59,14 +59,15 @@ function Get-TargetResource { | |||
|
|||
if ($Credential) { | |||
AddInvokeScriptBlockCredentials -Hashtable $invokeCommandParams -Credential $Credential; | |||
Write-Verbose ($localizedData.InvokingScriptBlockWithParams -f [System.String]::Join("','", @($Name, $Enabled, $Ensure))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move the Write-Verbose call above the if ($Credential) {
call? This will ensure the verbose logs is output whether -Credential
or -PSDscRunAsCredential
is used.
@@ -194,14 +195,13 @@ function Set-TargetResource { | |||
|
|||
if ($Credential) { | |||
AddInvokeScriptBlockCredentials -Hashtable $invokeCommandParams -Credential $Credential; | |||
Write-Verbose ($localizedData.InvokingScriptBlockWithParams -f [System.String]::Join("','", @($Name, $Enabled, $Ensure))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move the Write-Verbose call above the if ($Credential) {
call and the same for all other instances across all these files?
@@ -30,18 +30,19 @@ function Get-TargetResource { | |||
|
|||
} #end begin | |||
process { | |||
|
|||
#Running scriptblock without invoke-command, so no need for $using: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still need to use $using:
and PSRemoting for v4 compatibility and therefore, they need to be put back.
$scriptBlock = { | ||
|
||
Import-Module "$env:ProgramFiles\Citrix\XenDesktopPoshSdk\Module\Citrix.XenDesktop.Admin.V1\Citrix.XenDesktop.Admin\Citrix.XenDesktop.Admin.psd1" -Verbose:$false; | ||
|
||
$xdSite = Get-XDSite -AdminAddress $using:ExistingControllerName -ErrorAction Stop; | ||
$xdSite = Get-XDSite -AdminAddress $ExistingControllerName -ErrorAction Stop; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert to $using:
$targetResource = @{ | ||
SiteName = $xdSite.Name; | ||
ExistingControllerName = $using:ExistingControllerName; | ||
ExistingControllerName = $ExistingControllerName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert to $using:
Ensure = 'Absent'; | ||
} | ||
if (($xdSite.Name -eq $using:SiteName) -and ($xdSite.Controllers.DnsName -contains $using:localHostName)) { | ||
if (($xdSite.Name -eq $SiteName) -and ($xdSite.Controllers.DnsName -contains $localHostName)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert to $using:
@@ -147,7 +148,7 @@ function Set-TargetResource { | |||
|
|||
} #end begin | |||
process { | |||
|
|||
##Not sure if what I did above caused this, but when set to 'Absent' this block will remove the $existing controller instead of the one you're running the script from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so and it looks like the wrong implementation and needs to be changed. Can you remove this comment and open an issue to get it fixed?
}; | ||
|
||
return $targetResource; | ||
} #end scriptblock | ||
|
||
<# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove comment and implement the & $invokeCommandParams.ScriptBlock
call as per all the other functions.
@@ -62,12 +62,12 @@ function Get-TargetResource { | |||
LicenseEdition = $xdSiteConfig.ProductEdition; | |||
LicenseModel = $xdSiteConfig.LicensingModel; | |||
TrustLicenseServerCertificate = !([System.String]::IsNullOrEmpty($xdSiteConfig.MetaDataMap.CertificateHash)); | |||
Ensure = $using:Ensure; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reinstate the $using:
call.
@@ -215,4 +213,4 @@ $moduleRoot = Split-Path -Path $MyInvocation.MyCommand.Path -Parent; | |||
$moduleParent = Split-Path -Path $moduleRoot -Parent; | |||
Import-Module (Join-Path -Path $moduleParent -ChildPath 'VE_XD7Common'); | |||
|
|||
Export-ModuleMember -Function *-TargetResource; | |||
Export-ModuleMember -Function *-TargetResource; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File should have an empty blank line at the end.
Shift the return of invoke-command scriptblock up into if credential. If no credential, replace $using: as before, but execute with the call operator. If psdscrunascredentials are provided, they will be used. If not, system.