Files, Folders and the Registry
- Items: Support for *-Items cmdlet varies from Provider to Provider
- Test for Existing Items:
Test-Path - To Check for existense of folder or file
$folderPath = 'c:\windows\system32' Test-Path $folderPath # To check if it is folder and whether it exists or not Test-Path $folder -PathType 'Container' # To check if it is file and whether it exists or not $filePath = 'c:\test1.txt' Test-Path $filePath -PathType 'Leaf'- Create and deleting Items. The
New-Itemcan create files, directory, registry keys, certificates and also environmental variable and to delete the items we haveRemove-Item - Item-Properties: To deal with item properties we have two cmdlets
- Get-ItemProperty
- Set-ItemProperty
- A File has following possible attributes
- Name
- Compressed
- Archive
- System
- Hidden
- Read-Only
- Permissions: To deal with permissions we have two cmdlets
Get-Acl&Set-Acl
- Test for Existing Items:
- Sample Script to Create Files and Folders
Next Steps:
- Remoting and Remote Management
