Changed scripts

This commit is contained in:
Gramzon
2025-01-13 16:02:43 +01:00
parent aab627947c
commit 76f1e79161
6 changed files with 179 additions and 4 deletions
+72
View File
@@ -0,0 +1,72 @@
#install active directory.
# THIS SCRIPT MUST BE RUN AS ADMINISTRATOR ON DC1
#language, time and timezone settings:
# Se hvilke språkpakker (capabilities) som er tilgjengelige og evt. installert:
Get-WindowsCapability -Online -Name Language* |
Where-Object { $_.Name -like '*nb-NO*' } |
Format-Table -Autosize
# Installer Bokmål grunnpakke:
Add-WindowsCapability -Online -Name Language.Basic~~~nb-NO~0.0.1.0
# (Valgfritt) Installer OCR / TextToSpeech / Handwriting / Speech om ønskelig:
# Add-WindowsCapability -Online -Name Language.OCR~~~nb-NO~0.0.1.0
# Add-WindowsCapability -Online -Name Language.TextToSpeech~~~nb-NO~0.0.1.0
# Add-WindowsCapability -Online -Name Language.Handwriting~~~nb-NO~0.0.1.0
# Add-WindowsCapability -Online -Name Language.Speech~~~nb-NO~0.0.1.0
<# Checklist:
- Windows Update is up to date
- Time zone is correct
- Computer name is correct
- IP address is correct (non relevant for this lab)
- Keyboard layout is correct (Norwegian)
#>
# variable containing the computer name
$env:DC1
# If you want to change the computer name, you can use the Rename-Computer cmdlet
# $newcompname = Read-host "Skriv inn ønsket hostname på maskinen"
# Rename-Computer -Newname $newcompname -Restart -Force
# Check what features are installed
Get-WindowsFeature | Where-Object {$_. installstate -eq "installed"}
# Install Active Directory Domain Services (AD DS)
# Needs to be run as Administrator
Install-WindowsFeature AD-Domain-Services, DNS -IncludeManagementTools
$Password = Read-Host -Prompt 'Enter Password' -AsSecureString
Set-LocalUser -Password $Password Administrator
$Params = @{
DomainMode = 'WinThreshold'
DomainName = 'RohanIT.sec'
DomainNetbiosName = 'RohanIT'
ForestMode = 'WinThreshold'
InstallDns = $true
NoRebootOnCompletion = $true
SafeModeAdministratorPassword = $Password
Force = $true
}
# Install AD DS with the parameters defined above
Install-ADDSForest @Params
Restart-Computer
# Log in as Administrator@YourDomanName.whatever with password from above
# Test our domain
Get-ADRootDSE
# The Get-ADRootDSE cmdlet gets the object that represents the root of the directory information tree of a directory server.
# This tree provides information about the configuration and capabilities of the directory server,
# such as the distinguished name for the configuration container, the current time on the directory server,
# and the functional levels of the directory server and the domain.
#
Get-ADForest
# The Get-ADForest cmdlet gets the Active Directory forest specified by the parameters.
Get-ADDomain
# The Get-ADDomain cmdlet gets the Active Directory domain specified by the parameters.
# Any computers joined the domain?
Get-ADComputer -Filter * | Select-Object DNSHostName
+27
View File
@@ -0,0 +1,27 @@
# THIS SCRIPT MUST BE RUN AS ADMINISTRATOR ON SRV1, CLI1 and MGR
<# CHECKLIST:
- Windows Update is up to date
- Time zone is correct
- Set-TimeZone -id 'W. Europe Standard Time'
- Computer name is correct
- IP address is correct (non relevant for this lab)
- Keyboard layout is correct (Norwegian)
#>
# VM's for the lab needs DC1 IP-address as DNS server (must be done on VM's: SRV1, CLI1 and MGR)
# Why? Because the DNS server is the only one that knows about the domain
$ipaddressdc1 = "192.168.x.x" # IP-address of DC1
Get-NetAdapter | Set-DnsClientServerAddress -ServerAddresses $ipaddressdc1
# Check if configuration is correct
# Find DNS Servers . . . . . . . . . . . : IP.ADR.TIL.DC (192.168.x.x)
ipconfig /all
# Add the computer to the domain
$domainName = "RohanIT.sec" # replace with your domain name (e.g. InfraIT.sec)
$cred = Get-Credential -UserName "Wormtongue@$domainName" -Message 'Provide credentials for a domain admin'
Add-Computer -Credential $cred -DomainName $domainName -PassThru -Verbose
Restart-Computer
# When restarted, the computer will be joinedto the domain, and you can log in with a domain admin or user account
+21
View File
@@ -0,0 +1,21 @@
# TEST PSREMOTE: Connect-PSRemoting -ComputerName FROM MGR TO WORKSTATIONS/SERVERS IN DOMAIN
Enter-PSSession -ComputerName dc1
Enter-PSSession -ComputerName srv1
Enter-PSSession -ComputerName cl1
# Install PowerShell 7.x on remote machine.
# Enable-PSRemoting -Force <- This command must be run as administrator on remote machine if PSRemote dont work.
$session = New-PSSession -ComputerName dc1 -ConfigurationName PowerShell.7
Copy-Item -Path "C:\install\PowerShell-7.4.0-win-x64.msi" -Destination "C:\install" -ToSession $session
Invoke-Command -Session $session -ScriptBlock {
Start-Process "msiexec.exe" -ArgumentList "/i C:\install\PowerShell-7.4.0-win-x64.msi /quiet /norestart" -Wait
}
Invoke-Command -Session $session -ScriptBlock { $PSVersionTable }
# IF PSREMOTE DONT WORK, THIS COMMANDS MUST BE RUN AS ADMINISTRATOR ON VM'S WITH WINDOWS 10/11
# Enable PSRemote: Enable-PSRemoting -Force
Enable-PSRemoting -Force
winrm set winrm/config/service/auth '@{Kerberos="true"}'
# List auth:
winrm get winrm/config/service/auth
+29 -4
View File
@@ -1,5 +1,30 @@
#language, time and timezone settings: #language, time and timezone settings:
Set-TimeZone -Id "UTC+1" -Confirm #language, time and timezone settings:
Set-SystemLanguage no-NB # Se hvilke språkpakker (capabilities) som er tilgjengelige og evt. installert:
Set-WinSystemLocale no-NB Get-WindowsCapability -Online -Name Language* |
Set-WinUserLanguageList -LanguageList no-NB Where-Object { $_.Name -like '*nb-NO*' } |
Format-Table -Autosize
# Installer Bokmål grunnpakke:
Add-WindowsCapability -Online -Name Language.Basic~~~nb-NO~0.0.1.0
# (Valgfritt) Installer OCR / TextToSpeech / Handwriting / Speech om ønskelig:
# Add-WindowsCapability -Online -Name Language.OCR~~~nb-NO~0.0.1.0
# Add-WindowsCapability -Online -Name Language.TextToSpeech~~~nb-NO~0.0.1.0
# Add-WindowsCapability -Online -Name Language.Handwriting~~~nb-NO~0.0.1.0
# Add-WindowsCapability -Online -Name Language.Speech~~~nb-NO~0.0.1.0
# Sett Windows sin brukerliste for språk
# (NB: -Force hindrer bekreftelsesdialog):
Set-WinUserLanguageList -LanguageList nb-NO -Force
# Sett system-lokale:
Set-WinSystemLocale nb-NO
# Sett kultur (valutafomat, dato/klokkeslett osv.):
Set-Culture nb-NO
# Sett standard grensesnittspråk for UI (f.eks. "Press any key to continue"):
Set-WinUILanguageOverride nb-NO
+27
View File
@@ -0,0 +1,27 @@
# THIS SCRIPT MUST BE RUN AS ADMINISTRATOR ON DC1
# Define new user parameters
$username = "Wormtongue" # Change this to the desired username
$Password = Read-Host -Prompt 'Enter Password' -AsSecureString
$userPrincipalName = $username + "@" # Change to your domain
$displayName = "" # Change this to the desired display name
$description = "" # Change this to a suitable description
$path = "CN=Users,DC=<yourDomainName>,DC=<yourDomainNameEnding>" # Change the path to the appropriate path in your AD structure
# My path in the video CN=Users,DC=InfraIT,DC=sec (CN stands for Common Name, and DC stands for Domain Component)
# Users is a container in the root of the domain and not a OU (Organizational Unit)
# Create the new user
New-ADUser -Name $displayName `
-GivenName $username `
-UserPrincipalName $userPrincipalName `
-SamAccountName $username `
-AccountPassword $password `
-DisplayName $displayName `
-Description $description `
-Path $path `
-Enabled $true
# Add the new user to the Domain Admins group
Add-ADGroupMember -Identity "Domain Admins" -Members $username
Write-Host "User $username created and added to Domain Admins group."
+3
View File
@@ -25,3 +25,6 @@ foreach ($driver in $drivers) {
} }
Write-Output "All drivers have been updated." Write-Output "All drivers have been updated."
#install chocolatey
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))