Trying to bypass the script warning

Hi Everyone,

I’m hoping someone can help me with what may be a simple issue for an expert. I have a CSV file of users that I am using to create remote mailboxes on my hybrid Exchange server that will then sync to Office 365 via ADConnect. I am doing this via remoting into my Exchange box via this command…

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://hybrid.exchange.com/PowerShell/ -Authentication Kerberos -Credential $UserCredential

Then…

Import-PSSession $Session -DisableNameChecking

OK no problems there, I get connected. Once at the prompt, I am running this command to create the mailboxes…

Import-CSV -Path “C:\users\nsaenz\Documents\FWtest.csv” | ForEach-Object {New-RemoteMailbox -UserPrincipalName $.UserPrincipalName -Name $.Name -OnPremisesOrganizationalUnit $_.OnPremiseOrganizationalUnit }

It runs fine but for each user in my CSV file (there will be 100 or so), I get this warning for each mailbox…

cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
Credential
WARNING: A script or application on the remote computer HYBRID.EXCHANGE.COM is sending a prompt
request. When you are prompted, enter sensitive information, such as credentials or passwords, only if
you trust the remote computer and the application or script that is requesting the data.

Is there a way to bypass this so that I don’t have to enter my password 100 times?

Thanks as always in advance.

Nelson

$WarningPreference = SilentlyContinue

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_preference_variables?view=powershell-6

Thanks for replying. Is this a PS 6 specific feature? Doesn’t seem to work when I try it. I’m on PS 5 here.

Nelson

About CommonParameters exists since Powershell version 3.0 - released with Windows 8 - for almost 7 years now. :wink:

[quote quote=162428]Thanks for replying. Is this a PS 6 specific feature? Doesn’t seem to work when I try it. I’m on PS 5 here.

Nelson

[/quote]
You need to turn that on the remote computer where you’re invoking the commands

Ok, makes sense now. Thanks for explaining. Still learning so I appreciate it!

Nelson