-
-
Save aadennis/2fc4a587423773c090ebaaa0b938920f to your computer and use it in GitHub Desktop.
PS DSC - Basic transfer between servers in the same domain
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
# This lives on the Push Server | |
# https://dennisaa.wordpress.com/2017/01/11/powershell-dsc-using-a-push-server/ | |
Configuration BasicDscConfig { | |
Import-DscResource –ModuleName 'PSDesiredStateConfiguration' | |
$node = 'delposttest' | |
Node $node { | |
File MyRandomDir { | |
DestinationPath = "c:\temp\andMore" | |
Type = "Directory" | |
Recurse = $false | |
} | |
} | |
} | |
BasicDscConfig -InstanceName $node | |
Start-DscConfiguration -Path .\BasicDscConfig -Wait -Verbose -Force | |
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
Name of this is [delp2.westeurope.cloudapp.azure.com] | |
Later I realise because I am transferring across servers in the same domain, I don't have to qualify it with cloudapp.azure.com | |
Id CommandLine | |
-- ----------- | |
1 cd C:\sandbox\dsc | |
4 winrm quickconfig | |
5 $cred = Get-Credential | |
6 $sess = New-PSSession -ComputerName 'delp2.westeurope.cloudapp.azure.com' -Credential $cred | |
7 $sess = New-PSSession -ComputerName localhost -Credential $cred | |
8 $sess | |
9 ipconfig | |
12 Set-Item -Path WSMan:\localhost\Client\TrustedHosts -Value $computer | |
13 Get-Item -Path WSMan:\localhost\Client\TrustedHosts | |
15 $sess = New-PSSession -ComputerName $computer -Credential $cred | |
17 $computer = '10.2.1.5' | |
18 Set-Item -Path WSMan:\localhost\Client\TrustedHosts -Value $computer | |
19 $sess = New-PSSession -ComputerName $computer -Credential $cred | |
20 .\DoIt.ps1 | |
21 Get-History | |
22 Get-Item -Path WSMan:\localhost\Client\TrustedHosts | |
23 ipconfig.exe | |
24 ping 10.2.1.5 | |
25 ping 172.29.240.1 | |
26 Get-History | |
27 $computer = '172.29.240.1' | |
28 $computer = '10.2.1.5' | |
29 Set-Item -Path WSMan:\localhost\Client\TrustedHosts -Value $computer | |
30 Get-Item -Path WSMan:\localhost\Client\TrustedHosts | |
31 $sess = New-PSSession -ComputerName $computer -Credential $cred | |
32 .\DoIt.ps1 | |
37 ping delp2 | |
38 Get-History | |
39 $computer = delp2 | |
40 $computer = 'delp2' | |
41 Set-Item -Path WSMan:\localhost\Client\TrustedHosts -Value $computer | |
42 Get-Item -Path WSMan:\localhost\Client\TrustedHosts | |
43 $sess = New-PSSession -ComputerName $computer -Credential $cred | |
44 .\DoIt.ps1 | |
45 ls | |
46 cd .\BasicDscConfig\ | |
47 ls | |
48 del *.mof | |
49 cd .. | |
50 .\DoIt.ps1 | |
51 ls | |
52 cd .\BasicDscConfig\ | |
53 ls | |
54 del *.mof | |
55 cd .. | |
56 .\DoIt.ps1 | |
57 Get-History | |
58 ls | |
59 cd .\BasicDscConfig\ | |
60 ls | |
61 del *.mof | |
62 cd .. | |
63 Get-History | |
64 .\DoIt.ps1 | |
65 .\DoIt.ps1 | |
66 .\DoIt.ps1 | |
67 Get-History | |
68 $computer = "delposttest" | |
69 $sess = New-PSSession -ComputerName $computer -Credential $cred | |
70 Set-Item -Path WSMan:\localhost\Client\TrustedHosts -Value $computer | |
71 Get-Item -Path WSMan:\localhost\Client\TrustedHosts | |
72 Get-History | |
73 $sess = New-PSSession -ComputerName $computer -Credential $cred | |
74 $computer | |
75 ls | |
76 .\DoIt.ps1 | |
77 Get-History | |
78 Get-History | |
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
This is the receiving server called [delposttest.westeurope.cloudapp.azure.com] | |
Its Get-History is much shorter, a) because I did all the learning on the Pusher, b) its only action is to allow the Push Server to access it and execute actions on it | |
Id CommandLine | |
-- ----------- | |
1 $computer = 'delp2' | |
2 Set-Item -Path WSMan:\localhost\Client\TrustedHosts -Value $computer | |
3 winrm quickconfig | |
4 Get-Item -Path WSMan:\localhost\Client\TrustedHosts | |
5 Get-History | |
6 Get-History | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment