다음을 통해 공유


Get-Item

Gets the item at the specified ___location.

구문

Path (Default) - FileSystem provider

Get-Item
    [-Path] <String[]>
    [-Filter <String>]
    [-Include <String[]>]
    [-Exclude <String[]>]
    [-Force]
    [-Credential <PSCredential>]
    [-UseTransaction]
    [-Stream <String[]>]
    [<CommonParameters>]

LiteralPath - FileSystem provider

Get-Item
    -LiteralPath <String[]>
    [-Filter <String>]
    [-Include <String[]>]
    [-Exclude <String[]>]
    [-Force]
    [-Credential <PSCredential>]
    [-UseTransaction]
    [-Stream <String[]>]
    [<CommonParameters>]

Path (Default) - Certificate provider

Get-Item
    [-Path] <string[]>
    [-Filter <string>]
    [-Include <string[]>]
    [-Exclude <string[]>]
    [-Force]
    [-Credential <pscredential>]
    [-UseTransaction]
    [-CodeSigningCert]
    [-DocumentEncryptionCert]
    [-SSLServerAuthentication]
    [-DnsName <string>]
    [-Eku <string[]>]
    [-ExpiringInDays <int>]
    [<CommonParameters>]

LiteralPath - Certificate provider

Get-Item
    -LiteralPath <string[]>
    [-Filter <string>]
    [-Include <string[]>]
    [-Exclude <string[]>]
    [-Force]
    [-Credential <pscredential>]
    [-UseTransaction]
    [-CodeSigningCert]
    [-DocumentEncryptionCert]
    [-SSLServerAuthentication]
    [-DnsName <string>]
    [-Eku <string[]>]
    [-ExpiringInDays <int>]
    [<CommonParameters>]

Path (Default) - All providers

Get-Item
    [-Path] <string[]>
    [-Filter <string>]
    [-Include <string[]>]
    [-Exclude <string[]>]
    [-Force]
    [-Credential <pscredential>]
    [-UseTransaction]
    [<CommonParameters>]

LiteralPath - All providers

Get-Item
    -LiteralPath <string[]>
    [-Filter <string>]
    [-Include <string[]>]
    [-Exclude <string[]>]
    [-Force]
    [-Credential <pscredential>]
    [-UseTransaction]
    [<CommonParameters>]

Description

The Get-Item cmdlet gets the item at the specified ___location. It doesn't get the contents of the item at the ___location unless you use a wildcard character (*) to request all the contents of the item.

This cmdlet is used by PowerShell providers to navigate through different types of data stores. Some parameters are only available for a specific provider. For more information, see about_Providers.

예제

Example 1: Get the current directory

This example gets the current directory. The dot ('.') represents the item at the current ___location (not its contents).

Get-Item .
Directory: C:\

Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d----         7/26/2006  10:01 AM            ps-test

Example 2: Get all the items in the current directory

This example gets all the items in the current directory. The wildcard character (*) represents all the contents of the current item.

Get-Item *
Directory: C:\ps-test

Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d----         7/26/2006   9:29 AM            Logs
d----         7/26/2006   9:26 AM            Recs
-a---         7/26/2006   9:28 AM         80 date.csv
-a---         7/26/2006  10:01 AM         30 filenoext
-a---         7/26/2006   9:30 AM      11472 process.doc
-a---         7/14/2006  10:47 AM         30 test.txt

Example 3: Get the current directory of a drive

This example gets the current directory of the C: drive. The object that is retrieved represents only the directory, not its contents.

Get-Item C:

Example 4: Get items in the specified drive

This example gets the items in the C: drive. The wildcard character (*) represents all the items in the container, not just the container.

Get-Item C:\*

In PowerShell, use a single asterisk (*) to get contents, instead of the traditional *.*. The format is interpreted literally, so *.* wouldn't retrieve directories or filenames without a dot.

Example 5: Get a property in the specified directory

This example gets the LastAccessTime property of the C:\Windows directory. LastAccessTime is just one property of file system directories. To see all the properties of a directory, type (Get-Item <directory-name>) | Get-Member.

(Get-Item C:\Windows).LastAccessTime

Example 6: Show the contents of a registry key

This example shows the contents of the Microsoft.PowerShell registry key. You can use this cmdlet with the PowerShell Registry provider to get registry keys and subkeys, but you must use the Get-ItemProperty cmdlet to get the registry values and data.

Get-Item HKLM:\Software\Microsoft\PowerShell\1\Shellids\Microsoft.PowerShell\

Example 7: Get items in a directory that have an exclusion

This example gets items in the Windows directory with names that include a dot (.), but don't begin with w*.This example works only when the path includes a wildcard character (*) to specify the contents of the item.

Get-Item C:\Windows\*.* -Exclude "w*"

매개 변수

-CodeSigningCert

This is a dynamic parameter made available by the Certificate provider.

To get certificates that have Code Signing in their EnhancedKeyUsageList property value, use the CodeSigningCert parameter.

For more information, see about_Certificate_Provider.

매개 변수 속성

형식:SwitchParameter
Default value:None
와일드카드 지원:False
DontShow:False

매개 변수 집합

(All)
Position:Named
필수:False
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

-Credential

Note

This parameter isn't supported by any providers installed with PowerShell. To impersonate another user, or elevate your credentials when running this cmdlet, use Invoke-Command.

매개 변수 속성

형식:PSCredential
Default value:Current user
와일드카드 지원:False
DontShow:False

매개 변수 집합

(All)
Position:Named
필수:False
파이프라인의 값:False
속성 이름별 파이프라인의 값:True
나머지 인수의 값:False

-DnsName

This is a dynamic parameter made available by the Certificate provider.

Specifies a ___domain name or name pattern to match with the DNSNameList property of certificates the cmdlet gets. The value of this parameter can either be Unicode or ASCII. Punycode values are converted to Unicode. Wildcard characters (*) are permitted.

This parameter was reintroduced in PowerShell 7.1

For more information, see about_Certificate_Provider.

매개 변수 속성

형식:DnsNameRepresentation
Default value:None
와일드카드 지원:True
DontShow:False

매개 변수 집합

(All)
Position:Named
필수:False
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

-DocumentEncryptionCert

This is a dynamic parameter made available by the Certificate provider.

To get certificates that have Document Encryption in their EnhancedKeyUsageList property value, use the DocumentEncryptionCert parameter.

For more information, see about_Certificate_Provider.

매개 변수 속성

형식:SwitchParameter
Default value:None
와일드카드 지원:False
DontShow:False

매개 변수 집합

(All)
Position:Named
필수:False
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

-Eku

This is a dynamic parameter made available by the Certificate provider.

Specifies text or a text pattern to match with the EnhancedKeyUsageList property of certificates the cmdlet gets. Wildcard characters (*) are permitted. The EnhancedKeyUsageList property contains the friendly name and the OID fields of the EKU.

This parameter was reintroduced in PowerShell 7.1

For more information, see about_Certificate_Provider.

매개 변수 속성

형식:String
Default value:None
와일드카드 지원:True
DontShow:False

매개 변수 집합

(All)
Position:Named
필수:False
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

-Exclude

Specifies, as a string array, an item or items that this cmdlet excludes in the operation. The value of this parameter qualifies the Path parameter. Enter a path element or pattern, such as *.txt. Wildcard characters are permitted. The Exclude parameter is effective only when the command includes the contents of an item, such as C:\Windows\*, where the wildcard character specifies the contents of the C:\Windows directory.

매개 변수 속성

형식:

String[]

Default value:None
와일드카드 지원:True
DontShow:False

매개 변수 집합

(All)
Position:Named
필수:False
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

-ExpiringInDays

This is a dynamic parameter made available by the Certificate provider.

Specifies that the cmdlet should only return certificates that are expiring in or before the specified number of days. A value of zero (0) gets certificates that have expired.

This parameter was reintroduced in PowerShell 7.1

For more information, see about_Certificate_Provider.

매개 변수 속성

형식:Int32
Default value:None
와일드카드 지원:False
DontShow:False

매개 변수 집합

(All)
Position:Named
필수:False
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

-Filter

Specifies a filter to qualify the Path parameter. The FileSystem provider is the only installed PowerShell provider that supports filters. Filters are more efficient than other parameters. The provider applies filter when the cmdlet gets the objects rather than having PowerShell filter the objects after they're retrieved. The filter string is passed to the .NET API to enumerate files. The API only supports * and ? wildcards.

매개 변수 속성

형식:String
Default value:None
와일드카드 지원:True
DontShow:False

매개 변수 집합

(All)
Position:Named
필수:False
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

-Force

Indicates that this cmdlet gets items that can't otherwise be accessed, such as hidden items. Implementation varies from provider to provider. For more information, see about_Providers. Even using the Force parameter, the cmdlet can't override security restrictions.

매개 변수 속성

형식:SwitchParameter
Default value:False
와일드카드 지원:False
DontShow:False

매개 변수 집합

(All)
Position:Named
필수:False
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

-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. Enter a path element or pattern, such as *.txt. Wildcard characters are permitted. The Include parameter is effective only when the command includes the contents of an item, such as C:\Windows\*, where the wildcard character specifies the contents of the C:\Windows directory.

매개 변수 속성

형식:

String[]

Default value:None
와일드카드 지원:True
DontShow:False

매개 변수 집합

(All)
Position:Named
필수:False
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

-LiteralPath

Specifies a path to one or more locations. The value of LiteralPath is used exactly as it's typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.

For more information, see about_Quoting_Rules.

매개 변수 속성

형식:

String[]

Default value:None
와일드카드 지원:False
DontShow:False
별칭:PSPath

매개 변수 집합

LiteralPath
Position:Named
필수:True
파이프라인의 값:False
속성 이름별 파이프라인의 값:True
나머지 인수의 값:False

-Path

Specifies the path to an item. This cmdlet gets the item at the specified ___location. Wildcard characters are permitted. This parameter is required, but the parameter name Path is optional.

Use a dot (.) to specify the current ___location. Use the wildcard character (*) to specify all the items in the current ___location.

매개 변수 속성

형식:

String[]

Default value:None
와일드카드 지원:True
DontShow:False

매개 변수 집합

Path
Position:0
필수:True
파이프라인의 값:True
속성 이름별 파이프라인의 값:True
나머지 인수의 값:False

-SSLServerAuthentication

This is a dynamic parameter made available by the Certificate provider.

To get certificates that have Server Authentication in their EnhancedKeyUsageList property value, use the SSLServerAuthentication parameter.

For more information, see about_Certificate_Provider.

매개 변수 속성

형식:SwitchParameter
Default value:None
와일드카드 지원:False
DontShow:False

매개 변수 집합

(All)
Position:Named
필수:False
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

-Stream

This is a dynamic parameter made available by the FileSystem provider.

Gets the specified alternate NTFS file stream from the file. Enter the stream name. Wildcards are supported. To get all streams, use an asterisk (*). This parameter isn't valid on folders.

This parameter was introduced in PowerShell 3.0.

For more information, see about_FileSystem_Provider.

매개 변수 속성

형식:

String[]

Default value:No alternate file streams
와일드카드 지원:True
DontShow:False

매개 변수 집합

(All)
Position:Named
필수:False
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

-UseTransaction

Includes the command in the active transaction. This parameter is valid only when a transaction is in progress. For more information, see about_Transactions.

매개 변수 속성

형식:SwitchParameter
Default value:False
와일드카드 지원:False
DontShow:False
별칭:usetx

매개 변수 집합

(All)
Position:Named
필수:False
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

입력

String

You can pipe a string that contains a path to this cmdlet.

출력

AliasInfo

The cmdlet outputs this type when accessing the Alias: drive.

X509StoreLocation

X509Store

X509Certificate2

The cmdlet outputs these types when accessing the Cert: drive.

DictionaryEntry

The cmdlet outputs this type when accessing the Env: drive.

DirectoryInfo

FileInfo

The cmdlet outputs these types when accessing the FileSystem drives.

FunctionInfo

FilterInfo

The cmdlet outputs these types when accessing the Function: drives.

RegistryKey

The cmdlet outputs this type when accessing the Registry drives.

PSVariable

The cmdlet outputs this type when accessing the Variable: drives.

WSManConfigContainerElement

WSManConfigLeafElement

The cmdlet outputs these types when accessing the WSMan: drives.

참고

Windows PowerShell includes the following aliases for Get-Item:

  • gi

This cmdlet does not have a Recurse parameter, because it gets only an item, not its contents. To get the contents of an item recursively, use Get-ChildItem.

To navigate through the registry, use this cmdlet to get registry keys and the Get-ItemProperty to get registry values and data. The registry values are considered to be properties of the registry key.

This cmdlet is designed to work with the data exposed by any provider. To list the providers available in your session, type Get-PSProvider. For more information, see about_Providers.