exam questions

Exam MD-100 All Questions

View all questions & answers for the MD-100 exam

Exam MD-100 topic 3 question 47 discussion

Actual exam question from Microsoft's MD-100
Question #: 47
Topic #: 3
[All MD-100 Questions]

Note: This question is part of a series of questions that present the same scenario. Each question in the series contains a unique solution that might meet the stated goals. Some question sets might have more than one correct solution, while others might not have a correct solution.
After you answer a question in this section, you will NOT be able to return to it. As a result, these questions will not appear in the review screen.
You have a computer that runs Windows 10. The computer contains a folder named D:\Scripts. D:\Scripts contains several PowerShell scripts.
You need to ensure that you can run the PowerShell scripts without specifying the full path to the scripts. The solution must persist between PowerShell sessions.
Solution: From PowerShell, you run $env:Path += ";d:\scripts\".
Does this meet the goal?

  • A. Yes
  • B. No
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Ptit_filou
Highly Voted 4 years, 6 months ago
https://stackoverflow.com/questions/714877/setting-windows-powershell-environment-variables "If, some time during a PowerShell session, you need to append to the PATH environment variable temporarily, you can do it this way: $env:Path += ";C:\Program Files\GnuWin32\bin" " I'd say No.
upvoted 9 times
WalkingOnAir
4 years, 5 months ago
You are right. To make a persistent change to an environment variable on Windows, use the System Control Panel. Select Advanced System Settings. On the Advanced tab, click Environment Variable.... You can add or edit existing environment variables in the User and System (Machine) scopes. Windows writes these values to the Registry so that they persist across sessions and system restarts. Alternately, you can add or change environment variables in your PowerShell profile. This method works for any version of PowerShell on any supported platform. Example: $path = [Environment]::GetEnvironmentVariable('PSModulePath', 'Machine') $newpath = $path + ';C:\Program Files\Fabrikam\Modules' [Environment]::SetEnvironmentVariable("PSModulePath", $newpath, 'Machine') https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-7.1 Answer is NO
upvoted 4 times
Alvaroll
2 years, 11 months ago
I think it's Yes. It seems that it's the profile option. "On Windows, there are three methods for making a persistent change to an environment variable: setting them in your profile, using the SetEnvironmentVariable method, and using the System Control Panel." https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-7
upvoted 1 times
Alvaroll
2 years, 11 months ago
Sorry, it's NO. The profile method needs to update a file located here $PROFILE and add the variables needed.
upvoted 2 times
...
...
...
...
dlast
Most Recent 2 years, 3 months ago
Selected Answer: B
Tested on 22H2 this does not work
upvoted 2 times
...
Hard1k
2 years, 3 months ago
ChatGPT says YES : Yes, running the command "$env:Path += ";d:\scripts"." in PowerShell will add the path "D:\Scripts" to the system's PATH environment variable. This will allow you to run PowerShell scripts located in the "D:\Scripts" folder without specifying the full path to the script. This change will persist between PowerShell sessions, allowing you to run the scripts from any location in the command prompt.
upvoted 1 times
Buruguduystunstugudunstuy
2 years, 3 months ago
The solution you provided using the `$env:Path` command is not persistent between sessions. The System Control Panel is a better option to make persistent changes to environment variables on Windows. Therefore, the correct answer is B. No. To make a persistent change to the PATH environment variable using the System Control Panel, follow these steps: 1. Open the System Control Panel by pressing the Windows key + Pause/Break 2. Click on the Advanced system settings link on the right-hand side of the window. 3. Click on the Environment Variables button. 4. Under System Variables, scroll down and find the Path variable. 5. Select the Path variable and click on Edit. 6. Click on New and add the path to the D:\Scripts folder (e.g., D:\Scripts). 7. Click OK to close all the windows.
upvoted 1 times
Buruguduystunstugudunstuy
2 years, 3 months ago
After making this change, you will be able to run PowerShell scripts located in the D:\Scripts folder without specifying the full path, and the change to the PATH environment variable will persist across sessions and system restarts. Alternatively, you can also add or change environment variables in your PowerShell profile. This method works for any version of PowerShell on any supported platform.
upvoted 1 times
...
...
...
williamlamata
2 years, 4 months ago
A. Yes. The command "$env:Path += ";d:\scripts"" is a valid solution to add the "D:\Scripts" folder to the system path so that you can run PowerShell scripts in that folder without specifying the full path. This command will append the string ";d:\scripts" to the existing value of the PATH environment variable for the current PowerShell session. The semicolon (;) separates each path in the PATH environment variable. The backslash () at the end of the path is required to ensure that the path is interpreted as a folder and not a file.
upvoted 1 times
...
ccontec
2 years, 4 months ago
Selected Answer: B
Answer is no, tested and works for a PS session but if you close and open other PS Session, doesn't work anymore
upvoted 1 times
...
Hatsapatsa
2 years, 6 months ago
Selected Answer: B
No. Tested this in a globalknowledge lab and it is not persistent.
upvoted 1 times
flabezerra
2 years, 5 months ago
I also believe this question does not reflect the answer clearly. Question 84 (which is part this series of questions) is more efficient to drive you to the System Properties.
upvoted 1 times
...
...
Hatsapatsa
2 years, 6 months ago
No. Tested this in a globalknowledge lab and it is not persistent.
upvoted 1 times
...
Crataeis
2 years, 8 months ago
Selected Answer: B
Answer is B
upvoted 1 times
...
Henry78
2 years, 11 months ago
So, are all the 3 choices of this scenario NO ?
upvoted 1 times
...
Rickert
2 years, 12 months ago
Selected Answer: B
No. It is just for the one session
upvoted 2 times
...
raduM
3 years ago
no is the correct answer
upvoted 1 times
...
ikhwanulrahim
3 years, 3 months ago
Selected Answer: B
Should be no
upvoted 1 times
...
daye
3 years, 4 months ago
Tested and it doesn't work, the variable is not persistent for other ps instances. You can easy test it $env:path $env:path +=";c:\test" open a new ps session $env:path
upvoted 1 times
...
neobahamutk
3 years, 5 months ago
Selected Answer: B
The anwer is B. To make a persistent change to an environment variable on Windows, use the System Control Panel. https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-7.2
upvoted 1 times
...
RoGr
3 years, 7 months ago
NO Given answer is not persistent
upvoted 1 times
...
Vileita
3 years, 7 months ago
Tested on Powershell, I'd say Yes.
upvoted 1 times
...
luciaalvesnog
3 years, 9 months ago
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-7 if answer is no why this link looks like diferent?
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...