Milestone 9 ‐ dc‐blue1, blue.local - ryanm292002/SEC480 GitHub Wiki
9.1
- Figuring out invoke-vmscript: ref: https://www.altaro.com/vmware/use-invoke-vmscript-powercli-cmdlet/
There are multiple things that need to be changed so I used parameters which essentially allowed me to use the strings from running the function ref:https://www.techtarget.com/searchwindowsserver/tip/Understanding-the-parameters-of-Windows-PowerShell-functions
function changewinip {
#define input parameters for the function, these are the string values that will be provided when running the function
param (
[Parameter(Mandatory=$true)]
[string]
$vm,
[Parameter(Mandatory=$true)]
[string]
$ipaddr,
[Parameter(Mandatory=$true)]
[string]
$subnetmask,
[Parameter(Mandatory=$true)]
[string]
$defaultgateway,
[Parameter(Mandatory=$true)]
[string]
$DNSnameserver,
[Parameter(Mandatory=$true)]
[string]
$ethernetdevice
)
- Try, catch statement (catch=error handling) with using invoke-vmscript to utilize netsh to change the IP, DNS, Gateway, Subnet mask. The DNS is seperate from the rest as it requires different command.
$InvokeIP = Invoke-VMScript -VM $targetVm -GuestCredential $cred -ScriptText "netsh interface ipv4 set address name='$ethernetname' static $ip $mask $gateway "
$InvokeDNS = Invoke-VMScript -VM $targetVm -GuestCredential $cred -ScriptText "netsh interface ipv4 add dns name='$ethernetname' $nameserver index=1"
- Full function can be found inside the 480utils.psm1, function is called "changewinip"
9.2
-
Create an Ansible Playbook to do the following on dc-blue1 to do the following
-
Set the local admin password
-
Set the hostname (followed by reboot)
-
Create a New Forest/Domain called something like BLUE.local (reboot)
-
Create OU structure in AD
-
https://docs.ansible.com/ansible/latest/collections/microsoft/ad/ou_module.html
-
Reference: https://docs.ansible.com/ansible/latest/collections/ansible/windows/index.html, basically had to install the windows "collection" and from there made the playbook using the collections documentation, wasnt too bad and the OU stuff was just copy and pasting and changing the parent directory.
- Install the windows collection which allows ansible to function with Windows devices.
ansible-galaxy collection install ansible.windows
- Running the ansible script through powershell, normally Id use winrm but powershell was what came up first during my research and seemed to work great.