Powershell.exe No Output
For my script I have 2 files in this folder and they both have the same file name so my 1st script can call my second script.
1st file (to my understanding) is a batch file that allows me to run my PS script as admin.
@ECHO OFF
PowerShell.exe -NoProfile -Command "& {Start-Process PowerShell.exe -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%~dpn0.ps1""' -Verb RunAs}"
PAUSE
2nd file is where I will be writing my PowerShell script. In my case I want my whole script to print out the current mapped drives, then with user input remove the unwanted drives, and then add any new drives if desired. And so far I am stuck with trying to print out current mapped drives because everytime I execute my batch file it executes my PS file and the PS.exe console is blank with no output of any kind. It only giving an output if I was to run it PS ISE but not in PS.exe, am i missing something?
$e = Get-WmiObject -Class Win32_MappedLogicalDisk | select Name, ProviderName
Write-Output $e
write-output "$e"
Write-Output "test"
cmd /c pause | out-null
powershell
add a comment |
For my script I have 2 files in this folder and they both have the same file name so my 1st script can call my second script.
1st file (to my understanding) is a batch file that allows me to run my PS script as admin.
@ECHO OFF
PowerShell.exe -NoProfile -Command "& {Start-Process PowerShell.exe -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%~dpn0.ps1""' -Verb RunAs}"
PAUSE
2nd file is where I will be writing my PowerShell script. In my case I want my whole script to print out the current mapped drives, then with user input remove the unwanted drives, and then add any new drives if desired. And so far I am stuck with trying to print out current mapped drives because everytime I execute my batch file it executes my PS file and the PS.exe console is blank with no output of any kind. It only giving an output if I was to run it PS ISE but not in PS.exe, am i missing something?
$e = Get-WmiObject -Class Win32_MappedLogicalDisk | select Name, ProviderName
Write-Output $e
write-output "$e"
Write-Output "test"
cmd /c pause | out-null
powershell
Why do you run the script as admin? Without modifying the keyHKLMSOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem
nad valueEnableLinkedConnections
you won't have access to user mode mappings.
– LotPings
Nov 20 at 15:12
I am running as admin because the final PS scrip will be renaming the computer and the current user wont have admin rights. So my though process is have (Non-Admin)user login run the .bat that will run the PS as admin to map drive and rename the computer. I will be physically by the computer as well. Granted I could do that all by hand but there are over 40 different user that I have to do this to.
– HowToGravity
Nov 20 at 15:56
add a comment |
For my script I have 2 files in this folder and they both have the same file name so my 1st script can call my second script.
1st file (to my understanding) is a batch file that allows me to run my PS script as admin.
@ECHO OFF
PowerShell.exe -NoProfile -Command "& {Start-Process PowerShell.exe -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%~dpn0.ps1""' -Verb RunAs}"
PAUSE
2nd file is where I will be writing my PowerShell script. In my case I want my whole script to print out the current mapped drives, then with user input remove the unwanted drives, and then add any new drives if desired. And so far I am stuck with trying to print out current mapped drives because everytime I execute my batch file it executes my PS file and the PS.exe console is blank with no output of any kind. It only giving an output if I was to run it PS ISE but not in PS.exe, am i missing something?
$e = Get-WmiObject -Class Win32_MappedLogicalDisk | select Name, ProviderName
Write-Output $e
write-output "$e"
Write-Output "test"
cmd /c pause | out-null
powershell
For my script I have 2 files in this folder and they both have the same file name so my 1st script can call my second script.
1st file (to my understanding) is a batch file that allows me to run my PS script as admin.
@ECHO OFF
PowerShell.exe -NoProfile -Command "& {Start-Process PowerShell.exe -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%~dpn0.ps1""' -Verb RunAs}"
PAUSE
2nd file is where I will be writing my PowerShell script. In my case I want my whole script to print out the current mapped drives, then with user input remove the unwanted drives, and then add any new drives if desired. And so far I am stuck with trying to print out current mapped drives because everytime I execute my batch file it executes my PS file and the PS.exe console is blank with no output of any kind. It only giving an output if I was to run it PS ISE but not in PS.exe, am i missing something?
$e = Get-WmiObject -Class Win32_MappedLogicalDisk | select Name, ProviderName
Write-Output $e
write-output "$e"
Write-Output "test"
cmd /c pause | out-null
powershell
powershell
asked Nov 20 at 14:21
HowToGravity
11
11
Why do you run the script as admin? Without modifying the keyHKLMSOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem
nad valueEnableLinkedConnections
you won't have access to user mode mappings.
– LotPings
Nov 20 at 15:12
I am running as admin because the final PS scrip will be renaming the computer and the current user wont have admin rights. So my though process is have (Non-Admin)user login run the .bat that will run the PS as admin to map drive and rename the computer. I will be physically by the computer as well. Granted I could do that all by hand but there are over 40 different user that I have to do this to.
– HowToGravity
Nov 20 at 15:56
add a comment |
Why do you run the script as admin? Without modifying the keyHKLMSOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem
nad valueEnableLinkedConnections
you won't have access to user mode mappings.
– LotPings
Nov 20 at 15:12
I am running as admin because the final PS scrip will be renaming the computer and the current user wont have admin rights. So my though process is have (Non-Admin)user login run the .bat that will run the PS as admin to map drive and rename the computer. I will be physically by the computer as well. Granted I could do that all by hand but there are over 40 different user that I have to do this to.
– HowToGravity
Nov 20 at 15:56
Why do you run the script as admin? Without modifying the key
HKLMSOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem
nad value EnableLinkedConnections
you won't have access to user mode mappings.– LotPings
Nov 20 at 15:12
Why do you run the script as admin? Without modifying the key
HKLMSOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem
nad value EnableLinkedConnections
you won't have access to user mode mappings.– LotPings
Nov 20 at 15:12
I am running as admin because the final PS scrip will be renaming the computer and the current user wont have admin rights. So my though process is have (Non-Admin)user login run the .bat that will run the PS as admin to map drive and rename the computer. I will be physically by the computer as well. Granted I could do that all by hand but there are over 40 different user that I have to do this to.
– HowToGravity
Nov 20 at 15:56
I am running as admin because the final PS scrip will be renaming the computer and the current user wont have admin rights. So my though process is have (Non-Admin)user login run the .bat that will run the PS as admin to map drive and rename the computer. I will be physically by the computer as well. Granted I could do that all by hand but there are over 40 different user that I have to do this to.
– HowToGravity
Nov 20 at 15:56
add a comment |
1 Answer
1
active
oldest
votes
To have access to user mode mappings when running as admin
you have to set a registry value
Batch code to set that registry key
:: Keep Net Use Drives in UAC Mode
Set "Key=HKLMSOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem"
Reg Add "%Key%" /f /v EnableLinkedConnections /t REG_DWORD /d 0x1
Do you mind elaborating a bit more? How would that allow me to print outGet-WmiObject -Class Win32_MappedLogicalDisk | select Name, ProviderName
on PS.exe? Would i just add that to my current batch file and have it run all together or would i have to run that before hand.
– HowToGravity
Nov 20 at 19:23
You rrun the batch file once, not sure if you've to logout and in again and when elevating you should have access to the mappings from the user.
– LotPings
Nov 20 at 19:25
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53395064%2fpowershell-exe-no-output%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
To have access to user mode mappings when running as admin
you have to set a registry value
Batch code to set that registry key
:: Keep Net Use Drives in UAC Mode
Set "Key=HKLMSOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem"
Reg Add "%Key%" /f /v EnableLinkedConnections /t REG_DWORD /d 0x1
Do you mind elaborating a bit more? How would that allow me to print outGet-WmiObject -Class Win32_MappedLogicalDisk | select Name, ProviderName
on PS.exe? Would i just add that to my current batch file and have it run all together or would i have to run that before hand.
– HowToGravity
Nov 20 at 19:23
You rrun the batch file once, not sure if you've to logout and in again and when elevating you should have access to the mappings from the user.
– LotPings
Nov 20 at 19:25
add a comment |
To have access to user mode mappings when running as admin
you have to set a registry value
Batch code to set that registry key
:: Keep Net Use Drives in UAC Mode
Set "Key=HKLMSOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem"
Reg Add "%Key%" /f /v EnableLinkedConnections /t REG_DWORD /d 0x1
Do you mind elaborating a bit more? How would that allow me to print outGet-WmiObject -Class Win32_MappedLogicalDisk | select Name, ProviderName
on PS.exe? Would i just add that to my current batch file and have it run all together or would i have to run that before hand.
– HowToGravity
Nov 20 at 19:23
You rrun the batch file once, not sure if you've to logout and in again and when elevating you should have access to the mappings from the user.
– LotPings
Nov 20 at 19:25
add a comment |
To have access to user mode mappings when running as admin
you have to set a registry value
Batch code to set that registry key
:: Keep Net Use Drives in UAC Mode
Set "Key=HKLMSOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem"
Reg Add "%Key%" /f /v EnableLinkedConnections /t REG_DWORD /d 0x1
To have access to user mode mappings when running as admin
you have to set a registry value
Batch code to set that registry key
:: Keep Net Use Drives in UAC Mode
Set "Key=HKLMSOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem"
Reg Add "%Key%" /f /v EnableLinkedConnections /t REG_DWORD /d 0x1
answered Nov 20 at 16:01
LotPings
17.4k61532
17.4k61532
Do you mind elaborating a bit more? How would that allow me to print outGet-WmiObject -Class Win32_MappedLogicalDisk | select Name, ProviderName
on PS.exe? Would i just add that to my current batch file and have it run all together or would i have to run that before hand.
– HowToGravity
Nov 20 at 19:23
You rrun the batch file once, not sure if you've to logout and in again and when elevating you should have access to the mappings from the user.
– LotPings
Nov 20 at 19:25
add a comment |
Do you mind elaborating a bit more? How would that allow me to print outGet-WmiObject -Class Win32_MappedLogicalDisk | select Name, ProviderName
on PS.exe? Would i just add that to my current batch file and have it run all together or would i have to run that before hand.
– HowToGravity
Nov 20 at 19:23
You rrun the batch file once, not sure if you've to logout and in again and when elevating you should have access to the mappings from the user.
– LotPings
Nov 20 at 19:25
Do you mind elaborating a bit more? How would that allow me to print out
Get-WmiObject -Class Win32_MappedLogicalDisk | select Name, ProviderName
on PS.exe? Would i just add that to my current batch file and have it run all together or would i have to run that before hand.– HowToGravity
Nov 20 at 19:23
Do you mind elaborating a bit more? How would that allow me to print out
Get-WmiObject -Class Win32_MappedLogicalDisk | select Name, ProviderName
on PS.exe? Would i just add that to my current batch file and have it run all together or would i have to run that before hand.– HowToGravity
Nov 20 at 19:23
You rrun the batch file once, not sure if you've to logout and in again and when elevating you should have access to the mappings from the user.
– LotPings
Nov 20 at 19:25
You rrun the batch file once, not sure if you've to logout and in again and when elevating you should have access to the mappings from the user.
– LotPings
Nov 20 at 19:25
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53395064%2fpowershell-exe-no-output%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Why do you run the script as admin? Without modifying the key
HKLMSOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem
nad valueEnableLinkedConnections
you won't have access to user mode mappings.– LotPings
Nov 20 at 15:12
I am running as admin because the final PS scrip will be renaming the computer and the current user wont have admin rights. So my though process is have (Non-Admin)user login run the .bat that will run the PS as admin to map drive and rename the computer. I will be physically by the computer as well. Granted I could do that all by hand but there are over 40 different user that I have to do this to.
– HowToGravity
Nov 20 at 15:56