Hi All,
While configuring pull server when a script with credentials is executed , it shows PlainTextPassword error.
Here is the script :
$username = “MW\biswaa”
$password = Read-Host -AsSecureString
$cred = new-object -typename System.Management.Automation.PSCredential `
-argumentlist $username, $password
$content = Get-Content “D:\demo.json” | Out-String
$parsejson = ConvertFrom-Json $content
Configuration testconfig
{
param
(
[Parameter(Mandatory=$True)]
[string] $node,
[Parameter(Mandatory=$True)]
[pscredential]$cred
)
Node $node
{
File Copyfile
{
Ensure = "Present"
Type = "Directory"
SourcePath ="xxxxxxxxxxxxx"
DestinationPath = "xxxxxxxxxxxxx"
credential = $cred
}
}
}
foreach ($sitecontent in $parsejson)
{
$content = $sitecontent.Sites
$Node = $content.Server
write-host "Generating GUIDs and creating MOF files..."
$NewGUID = [guid]::NewGuid()
$NewLine = "{0},{1}" -f $Node,$NewGUID
$NewLine | add-content -path "$env:SystemDrive\Program Files\WindowsPowershell\DscService\Configuration\dscnodes.csv"
$config = @{
AllNodes = @(
@{
Nodename = $NewGUID
PSDSCAllowPlainTextPassword = $true
}
)
}
TestConfig -node $NewGUID -cred $cred -ConfigurationData $config
Write-Host "Found Node - " +$Node
}
Error ::
ConvertTo-MOFInstance : System.InvalidOperationException error processing property ‘Credential’ OF TYPE ‘Script’: Converting and storing encrypted passwords as plain text is not
recommended. For more information on securing credentials in MOF file, please refer to MSDN blog: http://go.microsoft.com/fwlink/?LinkId=393729
When I am giving Node name , it works fine, but the issue occurs if GUID is involved in it.