Normalizza utente locale nei task
This commit is contained in:
@@ -19,6 +19,19 @@ $ErrorActionPreference = "Stop"
|
|||||||
$repoRoot = Split-Path -Parent $PSScriptRoot
|
$repoRoot = Split-Path -Parent $PSScriptRoot
|
||||||
$pythonExe = (& python -c "import sys; print(sys.executable)").Trim()
|
$pythonExe = (& python -c "import sys; print(sys.executable)").Trim()
|
||||||
|
|
||||||
|
function Resolve-TaskUserName {
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$Name
|
||||||
|
)
|
||||||
|
|
||||||
|
if ($Name.StartsWith(".\")) {
|
||||||
|
return "$env:COMPUTERNAME\$($Name.Substring(2))"
|
||||||
|
}
|
||||||
|
|
||||||
|
return $Name
|
||||||
|
}
|
||||||
|
|
||||||
if (-not $pythonExe -or -not (Test-Path -LiteralPath $pythonExe)) {
|
if (-not $pythonExe -or -not (Test-Path -LiteralPath $pythonExe)) {
|
||||||
$pythonCommand = Get-Command python -ErrorAction Stop
|
$pythonCommand = Get-Command python -ErrorAction Stop
|
||||||
$pythonExe = $pythonCommand.Source
|
$pythonExe = $pythonCommand.Source
|
||||||
@@ -79,6 +92,7 @@ if ($RunAsStoredCredentials) {
|
|||||||
if (-not $UserName) {
|
if (-not $UserName) {
|
||||||
$UserName = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
|
$UserName = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
|
||||||
}
|
}
|
||||||
|
$UserName = Resolve-TaskUserName -Name $UserName
|
||||||
|
|
||||||
$securePassword = Read-Host -Prompt "Password for $UserName" -AsSecureString
|
$securePassword = Read-Host -Prompt "Password for $UserName" -AsSecureString
|
||||||
$passwordPtr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($securePassword)
|
$passwordPtr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($securePassword)
|
||||||
|
|||||||
Reference in New Issue
Block a user