PowerShell Get-ItemProperty Cmdlet
Hello Everyone
Welcome to CloudAffaire and this is Debjeet.
In the last blog post, we have discussed Set-Item cmdlet in PowerShell.
https://cloudaffaire.com/powershell-set-item-cmdlet/
In this blog post, we will discuss Get-ItemProperty cmdlet in PowerShell. You can use Get-ItemProperty cmdlet to get the properties of a specific item. Get-ItemProperty cmdlet is mainly used to get property of a file, directory or registry key in PowerShell. You define the location of the item using ‘path’ argument and property to retrieve using ‘name’ argument.
Get-ItemProperty Cmdlet Syntax:
1 2 3 4 5 6 7 8 9 |
## Get-ItemProperty ## [-Path] ## [[-Name] ## [-Filter ## [-Include ## [-Exclude ## [-Credential ## [-UseTransaction] ## [ |
Get-ItemProperty Cmdlet Argument List:
- –Credential: To impersonate another user or elevate your credentials.
- –Exclude: Specifies, as a string array, an item or items that this cmdlet excludes from the operation. The value of this parameter qualifies the Path parameter.
- –Filter: Specifies a filter in the format or language of the provider. The value of this parameter qualifies the Path parameter.
- –Include: Specifies, as a string array, an item or items that this cmdlet includes in the operation. The value of this parameter qualifies the Path parameter.
- –LiteralPath: Specifies the path to the current location of the property. Unlike the Path parameter, the value of LiteralPath is used exactly as it is typed.
- –Name: Specifies the name of the property or properties to retrieve.
- –Path: Specifies the path to the item or items.
- –UseTransaction: Includes the command in the active transaction. This parameter is valid only when a transaction is in progress.
PowerShell Get-ItemProperty Cmdlet:
List The Contents Of A Directory In PowerShell:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
############################################ ## PowerShell | Cmdlet | Get-ItemProperty ## ############################################ ## PowerShell Latest Version (5) ## create a file, directory and registry key New-Item -Path HKCU:\Software -Name MyRegKey -Value "Hello World" New-Item -ItemType Directory -Path C:\MyDir\ New-Item -ItemType Directory -Path C:\MyDir\MyDir1 New-Item -ItemType File -Path C:\MyDir\MyFile1 ## get contents of a directory in PowerShell Get-ItemProperty -Path C:\MyDir\* |
Get Properties Of A Directory In PowerShell:
1 2 3 4 5 |
## get properties of a directory in PowerShell Get-ItemProperty -Path C:\MyDir\MyDir1 Get-ItemProperty -Path C:\MyDir\MyDir1 | Select-Object * |
Get Properties Of A File In PowerShell:
1 2 3 4 5 |
## get properties of a file in PowerShell Get-ItemProperty -Path C:\MyDir\MyFile1 Get-ItemProperty -Path C:\MyDir\MyFile1 | Select-Object * |
Get Properties Of A Registry Key In PowerShell:
1 2 3 4 5 6 7 8 9 |
## get properties of a registry key in PowerShell Get-ItemProperty -Path HKCU:\Software\MyRegKey ## remove the items created for this demo Remove-Item -Path HKCU:\Software\MyRegKey Remove-Item -Path C:\MyDir -Recurse |
Hope you have enjoyed this article. In the next blog post, we will discuss Set-ItemProperty cmdlet in PowerShell.
To Set more details on PowerShell, kindly follow below official documentation