# Only working in Powershell 5 (NOT 7) with Admin rights
# Careful: Changes between English and German
$username = "simone"
# Prompt the user for the new user's password
$password = Read-Host "Enter the new user's password: " -AsSecureString
# Create the new user account
New-LocalUser -Name $username -Password $password -FullName "Ansible simone" -PasswordNeverExpires
# Add the new user to the Administrators group
Add-LocalGroupMember -Group Administrators -Member $username
Add-LocalGroupMember -Group Administratoren -Member $username
# List all  Administrators
Get-LocalGroup Administrators
Get-LocalGroup Administratoren
Get-LocalGroupMember -Group Administrators
Get-LocalGroupMember -Group Administratoren
# Write a message to the user
Write-Host "The new user account has been created and added to the Administrators group."

winrm quickconfig -transport:https
New-SelfSignedCertificate -DnsName ([System.Net.Dns]::GetHostByName($env:computerName)).Hostname -CertStoreLocation "cert:\LocalMachine\My" -FriendlyName Ansible
$dump = Get-ChildItem Cert:\LocalMachine\My | where FriendlyName -eq Ansible | select Thumbprint
New-WSManInstance -ResourceURI winrm/config/Listener -SelectorSet @{address="*";transport="https"} -ValueSet @{Hostname=[System.Net.Dns]::GetHostByName(($env:computerName)).Hostname;CertificateThumbprint=$dump.thumbprint}
winrm set winrm/config/service/auth '@{Basic="true"}'

# Check
winrm get winrm/config
winrm enumerate winrm/config/listener

# Add User
# PC -> Verwaltung -> User -> xxx
# Admin Group -> Add User -> xxx