70-740, Teil 1.2.4. Nanoserver verwalten und konfigurieren

70-740, Teil 1.2.4.

Nanoserver verwalten und konfigurieren

Ideen für die Recherche im Web:

technet Nanoserver verwalten und konfigurieren

Zum Nachschlagen:

https://technet.microsoft.com/de-de/windows-server-docs/get-started/manage-nano-server

Übungen:

#Beispiel 1

Set-Item WSMan:\localhost\Client\TrustedHosts “10.112.4.100”

Get-Item WSMan:\localhost\Client\TrustedHosts

$ip = “10.112.4.100”

$user = “$ip\Administrator”

Enter-PSSession -ComputerName $ip -Credential $user

HOSTNAME.EXE

Get-Command -CommandType Cmdlet

Exit-PSSession

$cim = New-CimSession -Credential $user -ComputerName $ip
#https://blogs.technet.microsoft.com/heyscriptingguy/2014/01/31/comparing-powershell-pssessions-and-cim-sessions/

Get-CimInstance -CimSession $cim -ClassName Win32_ComputerSystem | Format-List *

Get-CimInstance -CimSession $Cim -Query “SELECT * from Win32_Process”

get-vm

$VMName1 = “VM-NanoSrv1”

Enter-PSSession -VMName $VMName1 -Credential $user

Exit-PSSession

Enter-PSSession -VMName $VMName1 -Credential $user

Set-NetFirewallRule -DisplayGroup ‘Remote Event Log Management’ -Enabled True -PassThru | select DisplayName, Enabled

Enable-NetFirewallRule -DisplayGroup “Remote-Ereignisprotokollverwaltung”

Enable-NetFirewallRule -DisplayGroup “Remotedienstverwaltung”

Start-Service vds

Enable-NetFirewallRule -DisplayGroup “Datei- und Druckerfreigabe”

Enable-NetFirewallRule -DisplayGroup “Windows-Firewallremoteverwaltung”

Exit-PSSession

Enable-NetFirewallRule -DisplayGroup “Remotedienstverwaltung”

###

#Beispiel 2

dir D:\

Copy-Item D:\NanoServer\NanoServerImageGenerator -Destination C:\ -Recurse

cd C:\NanoServerImageGenerator

Get-ExecutionPolicy

# Bei Bedarf: Set-ExecutionPolicy RemoteSigned

Import-Module .\NanoServerImageGenerator -Verbose

New-NanoServerImage -DeploymentType Guest -Edition Datacenter -TargetPath .\wd-nano1A.vhdx -BasePath .\Base -ComputerName wd-nano1A -DomainName multi.media -EnableRemoteManagementPort -InterfaceNameOrIndex Ethernet -Ipv4Address 10.10.3.110 -Ipv4Dns 10.10.3.1 -Ipv4Gateway 10.0.3.1 -Ipv4SubnetMask 255.0.0.0 -ReuseDomainNode

New-NanoServerImage -DeploymentType Guest -Edition Datacenter -TargetPath .\wd-nano2B.vhdx -BasePath .\Base -ComputerName wd-nano2B -EnableRemoteManagementPort -InterfaceNameOrIndex Ethernet -Ipv4Address 10.10.3.220 -Ipv4Dns 10.10.3.1 -Ipv4Gateway 10.0.3.1 -Ipv4SubnetMask 255.0.0.0

New-NanoServerImage -DeploymentType Guest -Edition Datacenter -TargetPath .\wd-nano3C.vhdx -BasePath .\Base -ComputerName wd-nano3C -EnableRemoteManagementPort -InterfaceNameOrIndex Ethernet -Ipv4Address 10.10.3.133 -Ipv4Dns 10.10.3.1 -Ipv4Gateway 10.0.3.1 -Ipv4SubnetMask 255.0.0.0

$var_Switch = Get-VMSwitch -SwitchType External

$var_Switch.Name

New-VM -VHDPath .\wd-nano1A.vhdx -Generation 2 -MemoryStartupBytes 2GB -Name wd-nano1A -SwitchName $var_Switch.Name

New-VM -VHDPath .\wd-nano2B.vhdx -Generation 2 -MemoryStartupBytes 2GB -Name wd-nano2B -SwitchName $var_Switch.Name

New-VM -VHDPath .\wd-nano3C.vhdx -Generation 2 -MemoryStartupBytes 2GB -Name wd-nano3C -SwitchName $var_Switch.Name

Get-VM wd-nano2B

Start-VM wd-nano2B

$var_PSSession1_wd_nano1A = New-PSSession -ComputerName wd-nano1A

$var_PSSession1_wd_nano2B = New-PSSession -VMName wd-nano2B

Get-PSSession | ft Name, VMName, ComputerName -AutoSize

Invoke-Command -Session $var_PSSession1_wd_nano1A -ScriptBlock{(Get-ComputerInfo).CsDomain; Get-ComputerInfo | Select-Object *domain* | fl}

Invoke-Command -Session $var_PSSession1_wd_nano2B -ScriptBlock {Add-Computer -DomainName multi.media -Restart}
#https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/add-computer?view=powershell-5.1

if (((Get-ComputerInfo).CsDomainRole -eq “PrimaryDomainController”) -or ((Get-ComputerInfo).CsDomainRole -eq “BackupDomainController”)) {echo ja}

$var_Domain = (Get-ComputerInfo).CsDomain

djoin /provision /domain $var_Domain /machine wd_nano3C /savefile wd_nano3C.odj

dir wd_nano3C.odj

cat wd_nano3C.odj

notepad wd_nano3C.odj

Get-VM wd-nano3C | ft Name,State

Start-VM wd-nano3C

Get-Command *Copy*VM*

Get-VM wd-nano3C | Get-VMIntegrationService -Name “Gastdienstschnittstelle” | ft VMName, Name, Enabled

Get-VM wd-nano3C | Get-VMIntegrationService -Name “Gastdienstschnittstelle” | Enable-VMIntegrationService

Get-VM wd-nano3C | Get-VMIntegrationService -Name “Gastdienstschnittstelle” | ft VMName, Name, Enabled

Copy-VMFile wd-nano3C -SourcePath “.\wd_nano3C.odj” -DestinationPath “C:\Blob\wd_nano3C.odj” -CreateFullPath -FileSource Host

Enter-PSSession -VMName wd-nano3C -Credential “wd-nano3C\administrator”

dir “C:\Blob\wd_nano3C.odj”

(Get-ComputerInfo).CsDomain

djoin /requestodj /loadfile C:\Blob\wd_nano3C.odj /windowspath C:\Windows /localos

Restart-Computer

Enter-PSSession -VMName wd-nano3C -Credential “multi\administrator”

(Get-ComputerInfo).CsDomain

###

#Beispiel 3

dir C:\NanoServerImageGenerator\jb-2016nano1\jb-2016nano1.vhdx

explorer.exe C:\NanoServerImageGenerator\jb-2016nano1\jb-2016nano1.vhdx

get-command *mount*vhd*

Mount-VHD -Path C:\NanoServerImageGenerator\jb-2016nano1\jb-2016nano1.vhdx

get-help Mount-VHD

Mount-VHD -Path C:\NanoServerImageGenerator\jb-2016nano1\jb-2016nano1.vhdx -PassThru | Get-Disk | Get-Partition | Get-Volume

dir C:\Users\administrator\Documents

dir E:\Users\administrator\Documents

Copy-Item “C:\Users\administrator\Documents\*” -Destination “E:\Users\administrator\Documents” -Recurse

dir “E:\Users\administrator\Documents”

Dismount-VHD -Path C:\NanoServerImageGenerator\jb-2016nano1\jb-2016nano1.vhdx

dism /Get-ImageInfo /ImageFile:”C:\NanoServerImageGenerator\jb-2016nano1\jb-2016nano1.vhdx”

mkdir C:\Ordner1

dism /mount-image /ImageFile:”C:\NanoServerImageGenerator\jb-2016nano1\jb-2016nano1.vhdx” /MountDir:”C:\Ordner1″ /index:1

dir C:\Ordner1

Copy-Item “C:\Users\administrator\Documents\*” -Destination “C:\Ordner1\Users\administrator\Documents” -Recurse

dir “C:\Ordner1\Users\administrator\Documents”

dism /unmount-image /mountdir:”C:\Ordner1\” /commit