Board logo

标题: [转载代码] [PowerShell每日技巧]自动找借口(20131111) [打印本页]

作者: DAIC    时间: 2013-11-12 13:29     标题: [PowerShell每日技巧]自动找借口(20131111)

Tired of inventing lame excuses yourself? Then here's a script that gets you a new excuse any time you call Get-Excuse! All you need is Internet access:
  1. function Get-Excuse
  2. {
  3.   $url = 'http://pages.cs.wisc.edu/~ballard/bofh/bofhserver.pl'
  4.   $ProgressPreference = 'SilentlyContinue'
  5.   $page = Invoke-WebRequest -Uri $url -UseBasicParsing
  6.   $pattern = '<br><font size = "\+2">(.+)'
  7.   if ($page.Content -match $pattern)
  8.   {
  9.     $matches[1]
  10.   }
  11. }
复制代码
If your Internet access goes through a proxy or needs authentication, then look at the parameters of Invoke-WebRequest inside the function. You can submit proxy information as well as credentials.

http://powershell.com/cs/blogs/tips/archive/2013/11/11/getting-excuses-automatically.aspx
作者: 1270697389    时间: 2013-11-12 14:17

这个powerShell怎么用啊,是不是和bat一样保存为bat格式就可以了?
作者: DAIC    时间: 2013-11-12 15:42

回复 2# 1270697389


保存为test.ps1
作者: 1270697389    时间: 2013-11-12 17:28

回复  1270697389


保存为test.ps1
DAIC 发表于 2013-11-12 15:42


谢谢你!又学到了。
作者: 402853670    时间: 2013-11-13 22:04

提示: 该帖被管理员或版主屏蔽




欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2