more ps1 scripts

This commit is contained in:
Gramzon
2025-02-03 14:16:10 +01:00
parent 3f8a8fc637
commit 112f47e21e
4 changed files with 105 additions and 0 deletions
@@ -0,0 +1,24 @@
# In this script we will create a file share on the remote server to store the installation files.
$remoteComputerName = "srv1"
# Create a new POwerShell Session to the remote server
$session = New-PSSession -ComputerName $remoteComputerName
# Define the directory to create on the remote server
$newDirectory = "C:\shares\installfiles"
# Create the new directory on the remote server
Invoke-Command -Session $session -ScriptBlock {
param($newDirectory)
If(-not (Test-Path $newDirectory)) {
# Create the new directory if it does not exist
New-Item -Path $newDirectory -ItemType Directory
Write-Host "Directory created at $newDirectory"
} else {
Write-Host "Directory already exists at $newDirectory"
}
} -ArgumentList $newDirectory
# Close the PowerShell session
Remove-PSSession -Session $session