• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 46
  • Last Modified:

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
}
0
Edward Pamias
Asked:
Edward Pamias
  • 6
  • 3
1 Solution
 
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Improved Protection from Phishing Attacks

WatchGuard DNSWatch reduces malware infections by detecting and blocking malicious DNS requests, improving your ability to protect employees from phishing attacks. Learn more about our newest service included in Total Security Suite today!

  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now