34 lines
1.6 KiB
PowerShell
34 lines
1.6 KiB
PowerShell
# Fix root BAT files - Replace UPDATE.BAT and delete DEPLOY.BAT
|
|
$Password = ConvertTo-SecureString "Paper123!@#" -AsPlainText -Force
|
|
$Credential = New-Object System.Management.Automation.PSCredential("INTRANET\sysadmin", $Password)
|
|
|
|
Write-Host "[INFO] Connecting to AD2..." -ForegroundColor Cyan
|
|
$Session = New-PSSession -ComputerName 192.168.0.6 -Credential $Credential -ErrorAction Stop
|
|
Write-Host "[OK] Connected to AD2" -ForegroundColor Green
|
|
|
|
# Copy new UPDATE.BAT to root
|
|
Write-Host "[INFO] Replacing UPDATE.BAT in root..." -ForegroundColor Cyan
|
|
Copy-Item "D:\ClaudeTools\UPDATE-ROOT.BAT" -Destination "C:\Shares\test\UPDATE.BAT" -ToSession $Session -ErrorAction Stop
|
|
Write-Host "[OK] UPDATE.BAT replaced (now calls T:\COMMON\ProdSW\DEPLOY.BAT)" -ForegroundColor Green
|
|
|
|
# Delete DEPLOY.BAT from root
|
|
Write-Host "[INFO] Deleting DEPLOY.BAT from root..." -ForegroundColor Cyan
|
|
Invoke-Command -Session $Session -ScriptBlock {
|
|
if (Test-Path "C:\Shares\test\DEPLOY.BAT") {
|
|
Remove-Item "C:\Shares\test\DEPLOY.BAT" -Force
|
|
Write-Host "[OK] DEPLOY.BAT deleted from root" -ForegroundColor Green
|
|
} else {
|
|
Write-Host "[INFO] DEPLOY.BAT not found in root (already removed?)" -ForegroundColor Yellow
|
|
}
|
|
}
|
|
|
|
# Verify final state
|
|
Write-Host "`n[INFO] Verifying root BAT files..." -ForegroundColor Cyan
|
|
Invoke-Command -Session $Session -ScriptBlock {
|
|
Write-Host "`nBAT files in C:\Shares\test\:" -ForegroundColor Cyan
|
|
Get-ChildItem "C:\Shares\test\*.BAT" | Select-Object Name, Length, LastWriteTime | Format-Table -AutoSize
|
|
}
|
|
|
|
Remove-PSSession $Session
|
|
Write-Host "[SUCCESS] Root BAT files fixed" -ForegroundColor Green
|