http://www.iis.net/default.aspx?tabid=2&subtabid=25&i=1212

 

 

About Windows PowerShell

  • PS C:\> set-location Data
  • PS C:\Data> get-childitem Pow*
  • PS C:\Data> copy-item 'PowerShell' 'C:\Data\PSBackup' -recurse -force
    • 複製PowerShell資料夾及其底下所有的檔案與資料夾
  • PS C:\Data> remove-item PSBackup
    • 刪除PSBackup 資料夾及其底下所有的檔案與資料夾
  • PS C:\Data> get-content 'Hello.txt' | out-file '.\HelloCopy.txt'
  • PS C:\Data> get-content HelloCopy.txt
    • the get-content cmdlet is roughly equivalent to the type (Windows) or cat (Unix) commands
  • PS C:\Data> sl \
    • 使用set-location的alias sl 將目前路徑改為C:\
    • 查看sl為何者的alias
      • PS C:\> get-alias sl

             CommandType Name  Definition
              -----------           ----      ----------
                Alias               sl     Set-Location

Windows PowerShell in a Typical IIS 7 Environment

  • PS C:\> get-service
  • PS C:\> get-service -include w* | sort-object -property status
    • gsv w* | sort status
  • PS C:\> stop-service -servicename w3svc
    • spsv w3svc
  • PS C:\> get-process
  • PS C:\> get-process | sort-object -property handles
    PS C:\> $p = get-process
    PS C:\> $result = $p | measure-object -property handles -sum -average -max
    PS C:\> $result | out-file '.\ProcessHandleStats.txt'
    • gps | measure-object handles -sum -average -max |
              out-file '.\ProcessHandleStats.txt'
  • IIS 7 makes Web site deployment a simple matter of copying files
    • # file: Deploy-Application.ps1
    • $sourceMachine = "DemoServer1"
      $farmList = get-content '.\RestOfFarm.txt'
      $filesToCopy = get-content '.\AppManifest.txt'

      foreach ($targetMachine in $farmList)
      {
         foreach ($file in $filesToCopy)
         {
            $sourcePath = "\\" + (join-path $sourceMachine $file)
            $destPath   = "\\" + (join-path $targetMachine $file)
            write-host -for yellow "$targetMachine : Copying files from
              $sourcePath"

            copy-item $sourcePath $destPath
              -recurse -force
         }
      }

    • PS C:\> .\Deploy-Application.ps1   #執行該script檔
    • Join-Path C:\win* system* -Resolve
      C:\WINDOWS\system32
      C:\WINDOWS\system
      C:\WINDOWS\system.ini
      • 列出符合C:\win*\*system* 路徑的檔案或資料夾

Windows PowerShell with IIS 7

  • IIS 7 adds the powerful ability to cache dynamically created content.
  • #Consider this pre-release, IIS 7, Windows PowerShell cmdlet:
  • PS C:\> add-iiscaching                               
            -computer $computerlist
            -path Demo                  #points to the root path of the application
            -location index.php     #points to the target application
            -credential $cred         #$cred = get-credential  執行時會跳出小視窗以輸入帳號及密碼資訊 
            -extension .php          #specifies the type of application to cache
            -kernelcachepolicy 0   #not to cache kernel information
            -itemlocation 0           #specifies where to cache response information; 0 means store on either client or server
            -policy 1                     #means to continue caching until there is a change in the underlying cache element
            -varybyquerystring "Qwd,Qif,Qiv,Qis"    #query string
  •  

arrow
arrow
    全站熱搜

    ayowu 發表在 痞客邦 留言(0) 人氣()