1,导出至EXCEL

$arr =New-Object System.Collections.ArrayList
$i = 1
$pstablelist = @();
$array =get-user
do
{
IF ($array[$i].RecipientType -eq "UserMailbox")
{

$mbx=Get-CASMailbox $array[$i].name
   IF($mbx.OWAEnabled)
   {
    $arr.add("name:"+$array[$i].name+"    title:"+$array[$i].title );

    $table = @{"name"=$array[$i].name;"title"=$array[$i].title;}; 

    $pstable = New-Object -TypeName PSObject -Prop $table; 

    $pstablelist += $pstable;
   }
}

$i++;

}
while ($i -lt $array.Length)
$pstablelist | Export-Csv c:\test.csv -NoTypeInformation

2,

$ob1 = "foo"

Try
 {
 $ErrorActionPreference1 = "stop"
 $ErrorActionPreference11 = "stop"
 $ErrorActionPreference122 = "stop"
 $ErrorActionPreference221 = "stop"
$ob11= 11/0;
 }
Catch [System.Management.Automation.PSArgumentException]
 {
  "invalid object"
 }
Catch [System.Exception]
 {
   $_.Exception.Message;
  "caught a system exception"
 }
Finally
 {
  "end of script"
 }

 3,过滤

Get-MessageTrackingLog|?{$_.sourcecontext -eq '*12*'}|fl

Get-MessageTrackingLog|?{$_.sourcecontext -like '*12*'}|fl

Operator Description Example Result

-eq

equals

$a = 5 ; $a -eq 4

False

-ne

not equal

$a = 5 ; $a -ne 4

True

-gt

greater than

$a = 5 ; $a -gt 4

True

-ge

greater than or equal to

$a = 5 ; $a -ge 5

True

-lt

less than

$a = 5 ; $a -lt 5

False

-le

less than or equal to

$a = 5 ; $a -le 5

True

-like

wildcard comparison

$a = "This is Text" ; $a -like "Text"

False

-notlike

wildcard comparison

$a = "This is Text" ; $a -notlike "Text"

True

-match

regular expression comparison

$a = "Text is Text" ; $a -match "Text"

True

-notmatch

regular expression comparison

$a = "This is Text" ; $a -notmatch "Text$"

False

http://blogs.technet.com/b/heyscriptingguy/archive/2009/05/06/how-can-i-use-the-if-statement-in-windows-powershell.aspx

5,
Search-MailboxAuditLog js1 -ShowDetails -ResultSize 111/Unlimited | Sort-Object ItemSubject|fl itemsubject,identity -First 30

6, get the  compressed folder\files in  the  path C:\folder by powershell

gci -r C:\folder\ | where {$_.attributes -match "compressed"} | foreach {  $_.fullname }

gci -r C:\folder\ | where {$_.attributes -match "enr"} | foreach {  $_.fullname }

http://serverfault.com/questions/452529/view-find-all-compressed-files-on-the-server

powershell samples的更多相关文章

  1. Google App Engine10年,支持更多你喜欢的编程语言

    2008年4月7日google推出Google App Engine(GAE),时间过得真快,10年过去了,2010年3月google退出中国,一转眼也过去7年了.早在2009年的时候GAE就在中国内 ...

  2. WIN10 使用POWERSHELL 设置单应用KIOSK模式(win10家庭版或企业版)

    win10 使用PowerShell 设置单应用kiosk模式 win10 家版或企业版PowerShellshell 启动器 v1Autologon.exe 注意事项 win10 家庭版或企业版. ...

  3. 在PowerShell中使用curl(Invoke-WebRequest)

    前言 习惯了windows的界面模式就很难转去命令行,甚至以命令行发家的git也涌现出各种界面tool.然而命令行真的会比界面快的多,如果你是一个码农. situation:接到需求分析bug,需要访 ...

  4. Windows 7上执行Cake 报错原因是Powershell 版本问题

    在Windows 7 SP1 电脑上执行Cake的的例子 http://cakebuild.net/docs/tutorials/getting-started ,运行./Build.ps1 报下面的 ...

  5. <译>通过PowerShell工具跨多台服务器执行SQL脚本

    有时候,当我们并没有合适的第三方工具(大部分需要付费)去管理多台数据库服务器,那么如何做最省力.省心呢?!Powershell一个强大的工具,可以很方便帮到我们处理日常的数据库维护工作 .简单的几步搞 ...

  6. 利用PowerShell复制SQLServer账户的所有权限

    问题 对于DBA或者其他运维人员来说授权一个账户的相同权限给另一个账户是一个很普通的任务.但是随着服务器.数据库.应用.使用人员地增加就变得很枯燥乏味又耗时费力的工作.那么有什么容易的办法来实现这个任 ...

  7. PowerShell 数组以及XML操作

    PowerShell基础 PowerShell数组操作 将字符串拆分成数据的操作 cls #原始字符串 $str = "abc,def,ghi,mon" #数据定义 #$StrAr ...

  8. linux下mono,powershell安装教程

    1简介 简单来说pash就是bash+powershell 2官网 https://github.com/Pash-Project/Pash 3下载fedora20---lxde桌面---32位版. ...

  9. Windows下PowerShell监控Keepalived

    一.背景 某数据库服务器为CentOS,想要监控Keepalived的VIP是否有问题,通过邮件进行报警,但这台机器不能上外网,现在只能在Windows下通过PowerShell来完成发邮件预警. 二 ...

随机推荐

  1. 微软TechEd2013大会门票热卖!

    微软TechEd2013大会将在北京.上海两地隆重举行! 会议时间安排如下: 北京:12月5日—6日  国家会议中心 上海:12月11日—12日  国际会议中心 现在是门票热卖时期,票价:2688.0 ...

  2. objectarx 卸载加载arx模块

    通常情况下,加载卸载arx模块是使用 APPLOAD命令 使用ObjectARX 代码操作,也非常简单,使用2个全局函数即可,参数为名字有扩展名 C++ int acedArxLoad( const ...

  3. 算法导论 第六章 思考题 6-3 d叉堆

    d叉堆的实现相对于二叉堆变化不大,首先看它如何用数组表示. 考虑一个索引从1开始的数组,一个结点i最多可以有d个子结点,编号从id - (d - 2) 到 id + 1. 从而可以知道一个结点i的父结 ...

  4. jQuery基础学习笔记(1)

    --------2.0以上版本体积更小. --------CDN  内容分发网络(Content delivery network或Content distribution network,常简写成C ...

  5. 【转】Facebook React 和 Web Components(Polymer)对比优势和劣势

    原文转自:http://segmentfault.com/blog/nightire/1190000000753400 译者前言 这是一篇来自 StackOverflow 的问答,提问的人认为 Rea ...

  6. [转]<Unity3D>Unity3D的四种坐标系

    http://blog.csdn.net/zuoyamin/article/details/8813424 World Space(世界坐标):我们在场景中添加物体(如:Cube),他们都是以世界坐标 ...

  7. 换个心境搞IT,在IT职场如何打拼?

    刚进入IT这行时,我也是从程序员做起.尤其是前两三个月里,那种感觉就像时时刻刻处于备战状态一样.我是一个在对自己的要求方面有洁癖的人,在没有任何经验的状态下,只有坚持苦干,把下发的每件编程任务做好,才 ...

  8. url重写技术

    URL 重写是截取传入 Web 请求并自动将请求重定向到其他 URL 的过程.比如浏览器发来请求 hostname/101.aspx ,服务器自动将这个请求中定向为http://hostname/li ...

  9. 转:服务器控件的 ID,ClientID,UniqueID 的区别

    动态加载用户控件的怪问题 动态加载用户控件的时候,会因为调用一些控件的一些属性和方法而造成控件命名混乱. 因为add 一个用户控件或者 loadcontrol 的时候 如果没有指定控件的id,clie ...

  10. 《你不知道的JavaScript》第二部分:this 详解

    第1章 关于this this 是自动定义在所有函数的作用域中的关键字,用于引用合适的上下文对象. ☞ 为什么要使用 this ? this 提供了一种更优雅的方式来隐式"传递"一 ...