15 lines
596 B
PowerShell
15 lines
596 B
PowerShell
$password = ConvertTo-SecureString 'Paper123!@#' -AsPlainText -Force
|
|
$cred = New-Object System.Management.Automation.PSCredential('INTRANET\sysadmin', $password)
|
|
|
|
Write-Host "Adding AD2 SSH Key to NAS..." -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
Invoke-Command -ComputerName 192.168.0.6 -Credential $cred -ScriptBlock {
|
|
Write-Host "[1] Getting public key from AD2..." -ForegroundColor Yellow
|
|
$pubKey = Get-Content "$env:USERPROFILE\.ssh\id_ed25519.pub"
|
|
Write-Host " Key: $($pubKey.Substring(0, 60))..." -ForegroundColor Gray
|
|
|
|
# Return the key to the main script
|
|
return $pubKey
|
|
}
|