function Get-Version { $PSVersionTable.PSVersion } 以下示例中的函数是一个返回 PowerShell 版本的简单示例。 PowerShell 复制 Get-Version Output 复制 Major Minor Build Revision ----- ----- ----- -------- 5 1 14393 693 在为函数使用通用
自动$PSVersionTable变量在 PowerShell 5.1 及更高版本中还具有PSEdition属性: PowerShell $PSVersionTable Output Name Value --- --- PSVersion 7.3.9 PSEdition Core GitCommitId 7.3.9 OS Microsoft Windows 10.0.22621 Platform Win32NT PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} PSRemotin...
Add column to text file Add columns to PowerShell array and write the result to a table Add computer to AD group Add computers to domain in bulk / mass Add Computers to Security Group Based on OU Add current date to email subject line Add custom AD attribute to user depending on parent...
Format-Table: 用表格的形式显示内容。 Get-Service|Format-Table-Property DisplayName,Status DisplayName Status--- ---Agent Activation Runtime_958d60RunningAdobeUpdateServiceRunningAdobe Genuine Monitor ServiceRunningAdobe Genuine Software Integrity ServiceRunningAllJoyn Router Service Stopped 当内容超过屏幕的宽...
Get-NetFirewallRule | Format-Table -Property Name, DisplayName, Enabled, Action 文件和目录管理 获取目录中所有文件的详细信息: powershellCopy Code Get-ChildItem -Path "C:\Path\To\Directory" | Select-Object Name, Length, LastWriteTime 递归删除目录及其内容: powershellCopy Code Remove-Item -Path "...
colorscheme snazzyletg:SnazzyTransparent=1" 指定浏览器路径letg:mkdp_path_to_chrome="<此处填写chrome的安装路径>"" 指定预览主题,默认Githubletg:mkdp_markdown_css=''" Add spaces after comment delimiters bydefaultletg:NERDSpaceDelims=1" Use compact syntaxforprettified multi-line commentsletg:NERDCompa...
Add-Member現在可以在雜湊表上生效,即使尚未存取雜湊表也一樣。 Select-Object -Expand不會再於屬性值是 null 或空白時失敗或產生例外狀況。 現在,Get-Process可以在管線中搭配使用可從物件取得ComputerName屬性的其他命令。 ConvertTo-Json與ConvertFrom-Json現在可以接受以雙引號括住的詞彙,而且其錯誤訊息已可當地語...
Asset Name MemberType Definition --- --- --- Name NoteProperty string Name=Server30 PSVersion NoteProperty string PSVersion=4.0 System NoteProperty string System=Server Core $Asset.psobject.Properties | Format-Table Name, MemberType, TypeNameOfValue, Value Name MemberType TypeNameOfValue Value -...
Run script in 64-bit PowerShell host: Select Yes to run the script in a 64-bit PowerShell host on a 64-bit client architecture. Select No (default) runs the script in a 32-bit PowerShell host. When setting to Yes or No, use the following table for new and existing policy behavior...
The ChildObjectTypes parameter can only be used if the AccessRights parameter is set to CreateChild or DeleteChild. Expand table Type: ADSchemaObjectIdParameter[] Position: Named Default value: None Required: False Accept pipeline input: False Accept wildcard characters: False Applies to: Exchang...