Import-Module Microsoft.PowerShell.Utility Function SendWechat($user,$days) { $corpid = "wechat" $secret = "123-446" $agentid = "1000000" $auth_sring = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$corpid&corpsecret=$secret" $auth_values = Invoke-RestMethod $auth_sring $token = $auth_values.access_token $content = "$user 您好,您的邮箱密码即将在 $days 天后过期" $body = "{ `"touser`":`"$user`", `"agentid`":`"$agentid`", `"text`":{`"content`":`"$content`"}, `"msgtype`":`"text`" }" $body_u8 = [System.Text.Encoding]::UTF8.GetBytes($body) Invoke-RestMethod "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=$token" -ContentType "application/json" -Method Post -Body $body_u8 } $user = "zhangsan" SendWechat $user 6
标签:body,content,微信,auth,发送,token,user,corpid,PowerShell From: https://www.cnblogs.com/dreamer-fish/p/18297940