Welcome in the new Category of Askme4Tech. Here we try to automate IT Tasks with Powershell. PowerShell is an automation platform and scripting language for Windows and Windows Server that allows you to simplify the management of your systems. You don't need to install because it's installed bt default in Windows and Windows Server.
My first article will be something very simple but very diffcult to export at once. How can export all the subfolders names of a folder. It sounds very simple but it's not. So with Powershell you can do it in a minute.
You can use the Get-ChildItem to get subfolders of a folder.
- Open the Powershell
- Go in the folder that you want to export all the subfolder with cd or cd ..
gci -Directory | select parent, name | sort parent
The command will bring the 1st level of subfolders of the folder that you are.
<<gci is an alias of Get-ChildItem >>
- Now type
gci -Recurse -Directory | select parent, name | sort parent
and check the results
Bring all the subfolders of the folder that you are.
Now if you want these results to export in a csv file type
gci -Recurse -Directory | select parent, name | sort parent | Export-Csv -Path c:\powershelltest\folders.csv
Of course you can change the path of the csv file after -Path.
Open the folder that you export the csv file to find the file.
Very easy , quck without complexity.
Further reading about Powershell you can find in
Bye for now and i will come back with new commands to automate IT Tasks.