随笔 - 290  文章 - 10  评论 - 85  2

1.  set-executionpolicy remotesigned 打开系统执行脚本的权限

PowerShell 的文件在 C:\Windows\System32\WindowsPowerShell\v1.0 

注册表位置HKey_LocalMachine\Software\Windows\PowerShell

 

 2. 进入IIS状态:

get-module -listavailable

import webadministration

set-location IIS:\ 

get-command -module webadministration 

 

  View Code

3. 创建用户,加入用户组

$computername = $env:computername   # place computername here for remote access
$username = 'AdminAccount1'
$password = 'topSecret@99'
$desc = 'Automatically created local admin account'


$computer = [ADSI]"WinNT://$computername,computer"
$user = $computer.Create("user"$username)
$user.SetPassword($password)
$user.Setinfo()
$user.description = $desc
$user.setinfo()
$user.UserFlags = 65536
$user.SetInfo()
$group = [ADSI]("WinNT://$computername/administrators,group")

$group.add("WinNT://$username,user"


4. 参数的传递

命名参数 (例如Param($param1,$param2))的个数是用$psboundparameters.count ,而其他匿名的参数是在$args.coun所以总的参数个数是($psboundparameters.count + $args.count). 

1 CommandType     Name                            Definition                     
 2 -----------     ----                            ----------                     
 3 Cmdlet          Add-WebConfiguration            Add-WebConfiguration [-Filte...
 4 Cmdlet          Add-WebConfigurationLock        Add-WebConfigurationLock [-F...
 5 Cmdlet          Add-WebConfigurationProperty    Add-WebConfigurationProperty...
 6 Cmdlet          Backup-WebConfiguration         Backup-WebConfiguration [-Na...
 7 Alias           Begin-WebCommitDelay            Start-WebCommitDelay           
 8 Cmdlet          Clear-WebConfiguration          Clear-WebConfiguration [-Fil...
 9 Cmdlet          Clear-WebRequestTracingSettings Clear-WebRequestTracingSetti...
10 Cmdlet          ConvertTo-WebApplication        ConvertTo-WebApplication [[-...
11 Cmdlet          Disable-WebGlobalModule         Disable-WebGlobalModule [-Na...
12 Cmdlet          Disable-WebRequestTracing       Disable-WebRequestTracing [[...
13 Cmdlet          Enable-WebGlobalModule          Enable-WebGlobalModule [-Nam...
14 Cmdlet          Enable-WebRequestTracing        Enable-WebRequestTracing [[-...
15 Alias           End-WebCommitDelay              Stop-WebCommitDelay            
16 Cmdlet          Get-WebAppDomain                Get-WebAppDomain [-InputObje...
17 Cmdlet          Get-WebApplication              Get-WebApplication [[-Name] ...
18 Cmdlet          Get-WebAppPoolState             Get-WebAppPoolState [[-Name]...
19 Cmdlet          Get-WebBinding                  Get-WebBinding [[-Name] <Str...
20 Cmdlet          Get-WebConfigFile               Get-WebConfigFile [[-PSPath]...
21 Cmdlet          Get-WebConfiguration            Get-WebConfiguration [-Filte...
22 Cmdlet          Get-WebConfigurationBackup      Get-WebConfigurationBackup [...
23 Cmdlet          Get-WebConfigurationLocation    Get-WebConfigurationLocation...
24 Cmdlet          Get-WebConfigurationLock        Get-WebConfigurationLock [-F...
25 Cmdlet          Get-WebConfigurationProperty    Get-WebConfigurationProperty...
26 Cmdlet          Get-WebFilePath                 Get-WebFilePath [[-PSPath] <...
27 Cmdlet          Get-WebGlobalModule             Get-WebGlobalModule [[-Name]...
28 Cmdlet          Get-WebHandler                  Get-WebHandler [[-Name] <Str...
29 Cmdlet          Get-WebItemState                Get-WebItemState [[-PSPath] ...
30 Cmdlet          Get-WebManagedModule            Get-WebManagedModule [[-Name...
31 Cmdlet          Get-WebRequest                  Get-WebRequest [-InputObject...
32 Cmdlet          Get-Website                     Get-Website [[-Name] <String...
33 Cmdlet          Get-WebsiteState                Get-WebsiteState [[-Name] <S...
34 Cmdlet          Get-WebURL                      Get-WebURL [[-PSPath] <Strin...
35 Cmdlet          Get-WebVirtualDirectory         Get-WebVirtualDirectory [[-N...
36 Function        IIS:                            set-location IIS:              
37 Cmdlet          New-WebApplication              New-WebApplication [-Name] <...
38 Cmdlet          New-WebAppPool                  New-WebAppPool [-Name] <Stri...
39 Cmdlet          New-WebBinding                  New-WebBinding [[-Name] <Str...
40 Cmdlet          New-WebFtpSite                  New-WebFtpSite [-Name] <Stri...
41 Cmdlet          New-WebGlobalModule             New-WebGlobalModule [-Name] ...
42 Cmdlet          New-WebHandler                  New-WebHandler [-Name] <Stri...
43 Cmdlet          New-WebManagedModule            New-WebManagedModule [-Name]...
44 Cmdlet          New-Website                     New-Website [-Name] <String
>...
45 Cmdlet          New-WebVirtualDirectory         New-WebVirtualDirectory [-Na...
46 Cmdlet          Remove-WebApplication           Remove-WebApplication [-Name...
47 Cmdlet          Remove-WebAppPool               Remove-WebAppPool [-Name] <S...
48 Cmdlet          Remove-WebBinding               Remove-WebBinding [-Protocol...
49 Cmdlet          Remove-WebConfigurationBackup   Remove-WebConfigurationBacku...
50 Cmdlet          Remove-WebConfigurationLocation Remove-WebConfigurationLocat...
51 Cmdlet          Remove-WebConfigurationLock     Remove-WebConfigurationLock ...
52 Cmdlet          Remove-WebConfigurationProperty Remove-WebConfigurationPrope...
53 Cmdlet          Remove-WebGlobalModule          Remove-WebGlobalModule [-Nam...
54 Cmdlet          Remove-WebHandler               Remove-WebHandler [-Name] <S...
55 Cmdlet          Remove-WebManagedModule         Remove-WebManagedModule [-Na...
56 Cmdlet          Remove-Website                  Remove-Website [-Name] <Stri...
57 Cmdlet          Remove-WebVirtualDirectory      Remove-WebVirtualDirectory [...
58 Cmdlet          Rename-WebConfigurationLocation Rename-WebConfigurationLocat...
59 Cmdlet          Restart-WebAppPool              Restart-WebAppPool [[-Name] ...
60 Cmdlet          Restart-WebItem                 Restart-WebItem [[-PSPath] <...
61 Cmdlet          Restore-WebConfiguration        Restore-WebConfiguration [-N...
62 Cmdlet          Select-WebConfiguration         Select-WebConfiguration [-Fi...
63 Cmdlet          Set-WebBinding                  Set-WebBinding [[-Name] <Str...
64 Cmdlet          Set-WebConfiguration            Set-WebConfiguration [-Filte...
65 Cmdlet          Set-WebConfigurationProperty    Set-WebConfigurationProperty...
66 Cmdlet          Set-WebGlobalModule             Set-WebGlobalModule [-Name] ...
67 Cmdlet          Set-WebHandler                  Set-WebHandler [-Name] <Stri...
68 Cmdlet          Set-WebManagedModule            Set-WebManagedModule [-Name]...
69 Cmdlet          Start-WebAppPool                Start-WebAppPool [[-Name] <S...
70 Cmdlet          Start-WebCommitDelay            Start-WebCommitDelay [-Verbo...
71 Cmdlet          Start-WebItem                   Start-WebItem [[-PSPath] <St...
72 Cmdlet          Start-Website                   Start-Website [[-Name] <Stri...
73 Cmdlet          Stop-WebAppPool                 Stop-WebAppPool [[-Name] <St...
74 Cmdlet          Stop-WebCommitDelay             Stop-WebCommitDelay [[-PSPat...
75 Cmdlet          Stop-WebItem                    Stop-WebItem [[-PSPath] <Str...
posted on 2012-03-14 23:12  Gu  阅读(...)  评论(...编辑  收藏