Powershell Script modification - I need this script to prompt for ID and password.

I found a  script that can disable IPV6 remotely but due to some rules I am not allowed to save my ID and password in a file. Can some one modify this powershell script to prompt me for ID and password?

$adminPwd = "PASSWORD"
$compName = "REMOTECOMPUTERNAME"
 
$secPwd = ConvertTo-SecureString $adminPwd -AsPlainText -Force
$remoteCreds = New-Object System.Management.Automation.PSCredential ($adminUser, $secPwd)
$ServerSession = New-PSSession -ComputerName $compName -Authentication CredSSP -Credential $remoteCreds
 
Invoke-Command -Session $ServerSession -ScriptBlock
{
      # Disable IPv6
      $regPath = "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters"
      New-ItemProperty -Path $regPath -Name "DisabledComponents" -Value "0xFFFFFFFF" -PropertyType "DWORD" | Out-Null
      Restart-Computer -ComputerName $env:computername -Force
}
LVL 19
Edward PamiasTeam Lead RRS DeskAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oBdACommented:
Use Get-Credenitial; you can optionally add "-UserName Some\User" to pre-populate the Username field:
$compName = "REMOTECOMPUTERNAME"
$remoteCreds = Get-Credential -Message "Logon information to disable IPv6 on $($compName)"

$ServerSession = New-PSSession -ComputerName $compName -Authentication CredSSP -Credential $remoteCreds
Invoke-Command -Session $ServerSession -ScriptBlock {
	# Disable IPv6
	$regPath = "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters"
	New-ItemProperty -Path $regPath -Name "DisabledComponents" -Value "0xFFFFFFFF" -PropertyType "DWORD" | Out-Null
	Restart-Computer -Force
}

Open in new window

Note that technically, you shouldn't need the "-Authentication CredSSP", since there's no network activity taking place inside the script block.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Edward PamiasTeam Lead RRS DeskAuthor Commented:
Well the script runs but it does not work in this environment. I am going to close this out as the modification worked as I wanted. I need a script to disabled IPV6. I will post another question for that.
0
Edward PamiasTeam Lead RRS DeskAuthor Commented:
Thanks for the help.
0
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

Shaun VermaakTechnical Specialist/DeveloperCommented:
Why are you disabling IPv6?
0
Edward PamiasTeam Lead RRS DeskAuthor Commented:
As per my comment above the 3rd level team told us to do it. I am not sure how this fixes our problem with Office 365 not seeing an  internet connection, but it does. And these is over VPN, when they are in the office its fine.
0
Shaun VermaakTechnical Specialist/DeveloperCommented:
No comment above about Office.

I would not disable it and Microsoft directly advises against it. Can you please elaborate on the Office 365 not seeing an internet connection, if you want...
0
Edward PamiasTeam Lead RRS DeskAuthor Commented:
All depends on the user. One person could get activation screen another person could have a triangle on the top right next to their login and both users Office does not see the network. Any ideas?
0
Edward PamiasTeam Lead RRS DeskAuthor Commented:
One thing I forgot, this only happens at home while on VPN.
0
Edward PamiasTeam Lead RRS DeskAuthor Commented:
Shaun, I like the bottom link that is something we did not try. The top link never worked for me. I will reply back later in the week and let you know how it goes.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.