Windows Classroom Series – 06/Oct/2020

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-Item can create files, directory, registry keys, certificates and also environmental variable and to delete the items we have Remove-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
  • Sample Script to Create Files and Folders

Next Steps:

  • Remoting and Remote Management

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube