Skip to content
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

Merged
merged 13 commits into from
Jul 23, 2018

Conversation

justacurley
Copy link

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.

Copy link
Contributor

@iainbrighton iainbrighton left a 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)));
Copy link
Contributor

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)));
Copy link
Contributor

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:
Copy link
Contributor

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;
Copy link
Contributor

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;
Copy link
Contributor

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)) {
Copy link
Contributor

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
Copy link
Contributor

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

<#
Copy link
Contributor

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;
Copy link
Contributor

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;
Copy link
Contributor

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.

@iainbrighton iainbrighton merged commit 290126d into VirtualEngine:master Jul 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants