-
-
Save aadennis/82e7fedf584a6bba178bfdbe36d5e6d8 to your computer and use it in GitHub Desktop.
Creates a folder using DSC going from one Azure VM (effectively a Push Server) to another on the same subnet.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$sandbox = "C:\sandbox\PowerShell" | |
#$node = "backendvm1.uksouth.cloudapp.azure.com" | |
$node = "10.0.2.5" | |
$folderToCreate = "c:\TheDemo05" | |
$userName = "adguy" | |
if (-not ( Test-Path $sandbox)) { | |
New-Item -Type directory $sandbox | |
} | |
cd $sandbox | |
Set-Item -Path WSMan:\localhost\Client\TrustedHosts -Value $node | |
#By this point we expect Test-wsman to return a result... | |
$testWsmanResult = Test-WSMan -ComputerName $node | |
$testWsmanResult | |
if ($testWsmanResult -eq $null) { | |
Write-Error "WsMan connection to [$node] could not be made." | |
throw | |
} | |
Configuration BasicDscConfig { | |
Import-DscResource –ModuleName 'PSDesiredStateConfiguration' | |
node $node { | |
File MyRandomDir { | |
DestinationPath = $folderToCreate | |
Type = "Directory" | |
Recurse = $false | |
} | |
} | |
} | |
BasicDscConfig -InstanceName $node | |
if ($cred -eq $null) { | |
$cred = Get-Credential -UserName $userName -Message "Enter password" | |
} | |
Start-DscConfiguration -Path .\BasicDscConfig -Wait -Verbose -Force -Credential $cred |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment