Disclaimer:Hey Guys, this post contains affiliate link to help our reader to buy best product\service for them. It helps us because we receive compensation for our time and expenses.
Scenario: PS is most powerful and very helpful tool for windows and SQL server administrator and automation. So its today need to learn at least basic of some PS cmdlets.
In this series of tutorial, we will only walk through some of the basis and need to know cmdlets which will helps us in future in order to manage our SQL server.
For more details, you can google and look for good site.
Note:- Please click here to get 2nd part of PowerShell –SQL Automate tutorial.
The Get-Item cmdlet gets the items at a particular location.
To get content at particular location, use ‘*‘ wildcard character.
Get-Item [-Path] <String>] [-Include <String>] [-Filter <String>] [-Force] [-Exclude <String>] [-Stream <String>] [-Credential <PSCredential>] [<CommonParameters>]
The -Path parameter specifies the path to an item. The characters of wildcard are accepted. The -Path parameter is required, but the name ‘-Path‘ is optional.
You can use a ‘.’ to specify a current location. To specify all the items in the current location, use a ‘*’ asterisk.
The -LiteralPath parameter specifies a path to one or more location. Its value is used exactly as it is typed. Wildcards characters are not interpreted. If the path includes any escape character, then enclosed it in quotation marks. Single quotation mark tells the Windows PowerShell not to interpret any character as an escape sequence.
The -Force parameter indicate those items which cannot be accessed by a user such as hidden files. The implementation of this parameter is varied from provider to provider. Even using the -Force parameter, the cmdlet cannot override the security permissions.
The -Include parameter specifies as a string array, an item. It also specifies those items which this cmdlet includes in the operation. The value of -Include parameter qualifies the Path parameter. Enter a pattern or a path element, such as ‘*.txt‘.
This parameter is effective only when a cmdlet includes the contents of an item, such as ‘C:\Windows\*‘, where the wildcard character ‘*‘ specifies the contents of the C:\Windows directory.
The -Filter parameter is used to specify a filter to qualify the -Path parameter. The file system provider is the only installed provider of PowerShell, which supports the use of filters. This parameter is more efficient than other parameters because a provider applies them when the cmdlet retrieves the object, rather than having PowerShell filters the object after they are retrieved.
The -Exclude parameter specifies as a string array, a property. It also specifies those items which this cmdlet excludes from the operation. The value of -Exclude parameter qualifies the Path parameter. Wildcards characters are accepted.
Enter a pattern or a path element, such as A* or *.txt. Wildcard characters are permitted.
The -Stream parameter is used to get the particular alternate NTFS file stream from the file. Wildcard characters are supported. Use an asterisk ‘*‘ character to get all the streams. The -Stream parameter is not valid on folders.
It is a dynamic parameter and works only in the file system drives.
- To get current directory.
2. To get all the items in the current directory.
3. To get all the items in the specified directory.
4. To get a property in the specified directory
5. To display the content of a registry key
As soon as the fear approaches near, attack and destroy it.Chanakya