Powershell script running fine when running locally but when hosted on IIS server it is showing empty output

72 views Asked by At

My script looks like this -

$Computer_Object = $args[0]
$Bitlocker_Object = Get-ADObject -Filter {objectclass -eq 'msFVE-RecoveryInformation'} -SearchBase " DC=XX,DC=XX,DC=com" -Properties 'msFVE-RecoveryPassword' | where-object   {$_.DistinguishedName -like "*$Computer_Object*"} | Select-Object -First 1
$Bitlocker_Object | ConvertTo-JSON

And i am calling this script in a flask server

@app.route('/', methods = ['POST'])
#Getting the recovery key


def get_recovery_key():
    data = request.get_json()
    print(data['systemName'])
    script_path="C:/inetpub/Bitlocker_Key/react-app/Backend/Script.ps1"
    command = ['powershell.exe', '-ExecutionPolicy', 'Bypass', script_path]


    try:
        process = subprocess.run(command, stdout = subprocess.PIPE, stderr = subprocess.PIPE, universal_newlines = True) 
    # Capture standard output and error
        print(process.stdout)
        return {"output":process.stdout}
    except:
        return {"output":"There is some error in running query !!!"}

This is giving output when running locally but don't know how it is returning empty output string on IIS hosted site

{Output : ""}
0

There are 0 answers