Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从IIS执行powershell脚本时未找到命令_Powershell_Iis_Citrix - Fatal编程技术网

从IIS执行powershell脚本时未找到命令

从IIS执行powershell脚本时未找到命令,powershell,iis,citrix,Powershell,Iis,Citrix,我有一个脚本,可以在我们的平台上获取关系的citrix会话 问题是,当我从Web服务器上的控制台运行脚本时,脚本的执行是成功的,结果是预期的。 当我从我的网站(托管在IIS上)运行脚本时,结果如下: "The term 'Get-XASession' is not recognized as the name of a cmdlet, function, script file, or operable program." 以下是脚本: #-----------------------

我有一个脚本,可以在我们的平台上获取关系的citrix会话

问题是,当我从Web服务器上的控制台运行脚本时,脚本的执行是成功的,结果是预期的。 当我从我的网站(托管在IIS上)运行脚本时,结果如下:

"The term 'Get-XASession' is not recognized as the name of a cmdlet, function, script file, or operable program."
以下是脚本:

    #---------------------------------------------------------- 
    # PARAMS TO CALL SCRIPT WITH
    #---------------------------------------------------------- 
    Param(
        [string]$relationId,
        [string]$xaVersion,
        [string]$xaServer
    )

    #---------------------------------------------------------- 
    # LOAD ASSEMBLIES AND MODULES 
    #---------------------------------------------------------- 
    try
    {
        Import-Module "C:\Program Files\Citrix\XenApp 6.5 Server SDK\Citrix.XenApp.Sdk.ps1"

        . "D:\scripts\include\functions.ps1"
    }
    catch
    {
        return "[ERROR]`t Import module XenApp 6.5 Server SDK gives an error  $($_.Exception)"
    }

    #---------------------------------------------------------- 
    #START 
    #---------------------------------------------------------- 
    Set-ExecutionPolicy Unrestricted

    try
    {
        if ($xaVersion -eq "XA65")
        {
            $sessions = Get-XASession -ComputerName $xaServer | Where-Object { $_.AccountName -like "ASPECT\$relationId*" }
            $listSessions = @()
            foreach($se in $sessions)
            {
                New-Object psobject -Property @{AccountName = $se.AccountName; SessionId = $se.SessionId;  Name = $se.BrowserName; ClientName = $se.ClientName; ServerName = $se.ServerName; LogonTime = $se.LogonTime; Status = $se.State}
            }
            return $listSessions
        }
    }
    catch
    {
        return "[ERROR]`t Sessies ophalen voor gebruiker $samAccountName met XAversie $xaVersion gives the following error $($_.Exception)"
    }
IIS应用程序池的标识与我用于从控制台运行脚本的标识相同。 该用户拥有访问Citrix XenApp模块所需的所有权限

wierd的事情是,当我说Get命令Get XASession-neq$null时,脚本说,我知道该命令让我们去执行它。当它将要执行它时,sripts会说,是吗?从未受过伤害

我花了好几个小时,一点线索也没有


请帮帮我

jisaak确实让我走上了正确的方向

点源可能是答案,但这会给用户交互带来错误

这就是我所做的:我打开模块并将除了写主机行之外的所有内容复制到脚本中。我确实运行了它,猜猜看,它工作了

因此,如果您遇到与我相同的问题: 1.尝试点源 2.尝试将模块的内容复制到脚本中


所有学分归jisaak(Y):)

hm,您能尝试使用-global开关导入模块吗?谢谢您的评论-Global提供相同的结果您可以尝试使用点源导入ps1,就像您使用functions.ps1一样。或者您可以设置调试模式(设置psdebug-trace 2)以查看发生了什么