问题描述
我正在尝试获取迟到的用户并在我的 AD 中阻止他们,但我无法将数组从 PHP 传递到 powershell。
$array = array();
$loans = $db->Select("SELECT * FROM t_loan WHERE loaReturned = 1");
foreach($loans as $loan)
{
$personne = $db->Select("SELECT * FROM t_personne WHERE idPersonne = '" . $loan["fkPersonne"] . "'");
$prenom = $personne[0]['perSurname'];
$nom = $personne[0]['perName'];
$username = strtolower($prenom[0] . $nom);
array_push($array,$username);
}
$message = json_encode($array);
return $message;
并在这里使用它们:
# functions
. "$PSScriptRoot\function\Invoke-WebRequest-Preinfo.ps1"
# Get content of the request
$postParams = @{action="disableusers"}
$reqContent = Invoke-WebRequest-Preinfo -params $postParams
$jsonRes = $reqContent | ConvertFrom-Json
这是 Invoke-WebRequest 文件:
function Invoke-WebRequest-Preinfo
{
Param(
[parameter(Mandatory=$true)]
[Hashtable]
$params
)
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$req = Invoke-WebRequest -Uri "http://url/PHPscript.PHP" -Method Post -Body $params
return $req.Content
}
当我启动脚本时,$reqContent 为空
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)