Powershell 3 Flashcards

1
Q

What command would create a new folder called test1 in the below location?

c:\users\petej

A

new-item -path ‘c:\users\petej\test’ -itemtype directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What command would delete a folder called test1 from the below location?

c:\users\petej

A

Remove-item ‘c:\users\petej\test1’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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?

A

new-item ‘test1’ -itemtype directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the default Powershell file type?

A

.ps1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

A Powershell script cannot be run by double clicking it. How would you run a Powershell script?

A

Right click the file and select ‘Run with Powershell’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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

A

copy-item ‘c:\users\petej\desktop\music’ -destination ‘c:\users\petej\documents\Music Playlist’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the default editor for Windows Powershell?

A

Powershell ISE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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

A

new-item -path ‘c:\users\petej\desktop\Guitars\Fender’ -itemtype directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

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

A

test-path c:\users\petej\documents\Powershell

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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.

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly