Powershell 工作流实战(1)
2016-02-25 11:17
267 查看
假如说我们要写个powershell脚本,功能是找出禁用的账号,找出过期的账号,找出密码永不过期的账号,则可以运行以下三条语句即可。
还可以改成这样的
再或者,将它们单独放置,改成以下模式也是可以的
Search-ADAccount -AccountDisabled | Select-Object -Property DistinguishedName | Export-Csv -Path c:\workflow\01-DisabledAccounts.csv -NoTypeInformation Search-ADAccount -AccountExpired | Select-Object -Property DistinguishedName | Export-Csv -Path c:\workflow\02-ExpiredAccounts.csv -NoTypeInformation Search-ADAccount -PasswordNeverExpires | Select-Object -Property DistinguishedName | Export-Csv -Path c:\workflow\03-PsswdNeverExpireAccounts.csv -NoTypeInformation如果改成workflow脚本,则可以写成如下:
workflow get-ADReport { parallel { Search-ADAccount -AccountDisabled | Select-Object -Property DistinguishedName | Export-Csv -Path c:\workflow\01-DisabledAccounts.csv -NoTypeInformation Search-ADAccount -AccountExpired | Select-Object -Property DistinguishedName | Export-Csv -Path c:\workflow\02-ExpiredAccounts.csv -NoTypeInformation Search-ADAccount -PasswordNeverExpires | Select-Object -Property DistinguishedName | Export-Csv -Path c:\workflow\03-PsswdNeverExpireAccounts.csv -NoTypeInformation } }
还可以改成这样的
workflow get-ADReport { workflow get-disabled { Search-ADAccount -AccountDisabled | Select-Object -Property DistinguishedName | Export-Csv -Path c:\workflow\01-DisabledAccounts.csv -NoTypeInformation } workflow get-expired { Search-ADAccount -AccountExpired | Select-Object -Property DistinguishedName | Export-Csv -Path c:\workflow\02-ExpiredAccounts.csv -NoTypeInformation } workflow get-passwordneverexpire { Search-ADAccount -PasswordNeverExpires | Select-Object -Property DistinguishedName | Export-Csv -Path c:\workflow\03-PsswdNeverExpireAccounts.csv -NoTypeInformation } parallel { get-disabled get-expired get-passwordneverexpire } }
再或者,将它们单独放置,改成以下模式也是可以的
workflow get-disabled { Search-ADAccount -AccountDisabled | Select-Object -Property DistinguishedName | Export-Csv -Path c:\workflow\01-DisabledAccounts.csv -NoTypeInformation } workflow get-expired { Search-ADAccount -AccountExpired | Select-Object -Property DistinguishedName | Export-Csv -Path c:\workflow\02-ExpiredAccounts.csv -NoTypeInformation } workflow get-passwordneverexpire { Search-ADAccount -PasswordNeverExpires | Select-Object -Property DistinguishedName | Export-Csv -Path c:\workflow\03-PsswdNeverExpireAccounts.csv -NoTypeInformation } workflow get-ADReport { parallel { get-disabled get-expired get-passwordneverexpire } }
相关文章推荐
- shell 文本过滤器和SQL的比较
- 使用srcrpm包重新编译bash使之能够输出日志到rsyslog的local1
- Powershell工作流的限制
- linux shell脚本监控进程,如果进程不在,则重启之
- mac上的终端bash命令(一) Bourne-Again Shell简介\mac上的终端bash命令(二)基础
- JS + shell 批量下载 喜马拉雅FM 的音频
- 【小镇的技术天梯】Linux shell的标准输入、输出和错误
- XManager用Xshell上传和下载linux服务器的文件
- android adb shell 常用命令
- Windows PowerShell中scp命令
- linux-shell-#@!...
- Linux中执行shell脚本的4种方法总结
- 自己主动下载源代码_并编译_打包_部署_重新启动服务的Shell脚本
- 强行删除mac中的文件
- 排序——希尔排序(Shell Sort)
- PowerShell 工作流实战1
- shell编程之数组
- shell脚本常用命令简单总结
- shell编程注意事项
- shell实现linux到linux上传文件