How do you create a new directory in PowerShell?

Prepare for the WGU ITSW3170 D411 Scripting and Automation Exam. Utilize flashcards and multiple choice questions, each with hints and explanations, to enhance your study. Get exam-ready today!

To create a new directory in PowerShell, the approach of using "New-Item" with the parameter "-ItemType Directory" is the correct method. This command specifically instructs PowerShell to create an item of the type specified, which in this case is a directory. By using "New-Item -ItemType Directory" followed by the desired directory path, you ensure that PowerShell understands that you want to make a directory rather than any other type of item.

This command is not only effective but also versatile. It can be used to create various types of items by changing the "-ItemType" parameter (e.g., creating files, registry keys, etc.), making it a foundational command in PowerShell scripting.

The other options, although they use terminology that might suggest directory creation, are not valid PowerShell commands for this purpose and would result in errors if executed. Thus, "New-Item -ItemType Directory" is the standard, correct approach for creating directories in PowerShell.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy