# Deploy CTONW.BAT to AD2 via WinRM
$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

# Check/create directory on AD2
Write-Host "[INFO] Checking directory structure..." -ForegroundColor Cyan
Invoke-Command -Session $Session -ScriptBlock {
    if (-not (Test-Path "C:\Shares\test\COMMON\ProdSW")) {
        New-Item -Path "C:\Shares\test\COMMON\ProdSW" -ItemType Directory -Force | Out-Null
    }
}

Write-Host "[INFO] Copying CTONW.BAT to C:\Shares\test\COMMON\ProdSW..." -ForegroundColor Cyan
Copy-Item "D:\ClaudeTools\CTONW.BAT" -Destination "C:\Shares\test\COMMON\ProdSW\" -ToSession $Session -ErrorAction Stop
Write-Host "[OK] CTONW.BAT deployed to AD2:C:\Shares\test\COMMON\ProdSW\" -ForegroundColor Green

Remove-PSSession $Session
Write-Host "[SUCCESS] Deployment complete" -ForegroundColor Green
