Powershell 发送多个Web请求

Powershell 发送多个Web请求,powershell,Powershell,当我试图向Spectra磁带库发送多个请求时,我有以下代码- ** ** 第一个结果很好,它会登录,但当我发送第二个命令时,它会说:- <?xml version="1.0"?> <error> <message>You must go to login.xml and login before operating the library</message> <description>---- Error: No active

当我试图向Spectra磁带库发送多个请求时,我有以下代码-

**

**

第一个结果很好,它会登录,但当我发送第二个命令时,它会说:-

<?xml version="1.0"?>
<error>
  <message>You must go to login.xml and login before operating the library</message>
  <description>---- Error: No active session found.  
Visit login.xml to specify your username and password
</description>
</error>

在操作库之前,必须转到login.xml并登录
----错误:找不到活动会话。
访问login.xml指定用户名和密码

有什么帮助吗?

Toy应该使用登录保存会话,并将其用于第二个请求。像这样:

$results = Invoke-WebRequest -Uri "http://spectra1/gf/login.xml?username=administrator&password=xxxxxxx&forceFrontPanel" -SessionVariable spectra1Session
$results = Invoke-WebRequest -Uri "http://spectra1/gf/driveList.xml?action=list" -WebSession $spectra1Session -OutFile c:\temp\drivelist.txt

-SessionVariable spectra1Session
将会话保存在variable
$spectra1Session
中,然后
-WebSession$spectra1Session
使用保存的会话。

非常感谢,已经为此奋斗了一段时间了@如果适合你的情况,请联系cpj。
$results = Invoke-WebRequest -Uri "http://spectra1/gf/login.xml?username=administrator&password=xxxxxxx&forceFrontPanel" -SessionVariable spectra1Session
$results = Invoke-WebRequest -Uri "http://spectra1/gf/driveList.xml?action=list" -WebSession $spectra1Session -OutFile c:\temp\drivelist.txt