powershell PowerShell:Get-Win32ServicePathName
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell PowerShell:Get-Win32ServicePathName相关的知识,希望对你有一定的参考价值。
function Get-Win32ServicePathName {
[CmdletBinding(SupportsShouldProcess=$True,DefaultParameterSetName="None")]
PARAM(
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName="p1")]
[string[]]
$PathName
)
begin {
}
process {
foreach ($Path In $PathName) {
switch ($true) {
($Path -match '("([^"]+)")') {
$Matches[2]
break
}
($Path -match '(''([^'']+)'')') {
$Matches[2]
break
}
($Path -match '(^\S+)') {
$Matches[0]
break
}
}
}
}
end {
}
}
#region Get-PathNameFromCommandLine
function Get-PathNameFromCommandLine {
[CmdletBinding(SupportsShouldProcess=$True,DefaultParameterSetName="DefaultPS")]
PARAM (
[Alias("Path")]
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true, ParameterSetName="DefaultPS")]
[AllowNull()]
[AllowEmptyString()]
[string[]]
$PathName
)
begin {
}
process {
foreach ($Path In $PathName) {
# Modify the path so it can be cleaned-up correctly
if ((Test-Path -Path $Path -PathType Leaf) -eq $true -and ($Path.StartsWith("`"") -eq $false -or $Path.StartsWith("`"") -eq $false)) {
$Path = """$($Path)"""
}
switch ($true) {
# Match double quoted path
($Path -match '("([^"]+)")') {
$Matches[2]
break
}
# Match single quoted path
($Path -match '("([^"]+)")') {
$Matches[2]
break
}
($Path -match '(''([^'']+)'')') {
$Matches[2]
break
}
($Path -match '(^\S+)') {
$Matches[0]
break
}
}
}
}
end {
}
}
#endregion Get-PathNameFromCommandLine
以上是关于powershell PowerShell:Get-Win32ServicePathName的主要内容,如果未能解决你的问题,请参考以下文章
powershell PowerShell:Get-Handles
powershell PowerShell:Get-MicrosoftUpdates
powershell PowerShell:Get-NetPrefixPolicy
powershell PowerShell:Get-FileHash
powershell PowerShell:Get-ComparableVersion
powershell PowerShell:Get-OSBitness