Powershell 3 Flashcards
What command would create a new folder called test1 in the below location?
c:\users\petej
new-item -path ‘c:\users\petej\test’ -itemtype directory
What command would delete a folder called test1 from the below location?
c:\users\petej
Remove-item ‘c:\users\petej\test1’
What command would you use to create a folder called test1 when you are already in the directory that you want to create the folder in?
new-item ‘test1’ -itemtype directory
What is the default Powershell file type?
.ps1
A Powershell script cannot be run by double clicking it. How would you run a Powershell script?
Right click the file and select ‘Run with Powershell’
What command would copy a file called Music.txt from
c:\users\petej\desktop\
to
c:\users\petej\documents\
and rename it Music Playlist.txt
copy-item ‘c:\users\petej\desktop\music’ -destination ‘c:\users\petej\documents\Music Playlist’
What is the default editor for Windows Powershell?
Powershell ISE
How would you create a folder called Guitars with a subfolder called Fender? Use a single command to achieve this.
path c:\users\petej\desktop
new-item -path ‘c:\users\petej\desktop\Guitars\Fender’ -itemtype directory
What command would you use to check if a folder exists in a particular location?
Write an example to see if a folder called Powershell exists in c:\users\petej\documents
test-path c:\users\petej\documents\Powershell
What three commands would you use to create a .txt file, add content to the text file and then retrieve the content of the file and sisplay it in the powershell console?
Create the text file at c:\user\pete\users\desktop
and call it test.txt
Then add the below content
‘This is Content’
Now retrieve the content to display it in the powershell console.
new-item c:\users\petej\desktop\test.txt
set-content c:\users\petej\test.txt ‘This is Content’
get-content c:\users\petej\desktop\test.txt