Skip to main content
added 15 characters in body; edited title
Source Link
Fulproof
  • 101
  • 1
  • 4

Why does running Powershell script line by line work, but the same inthru executing script file - does not?

In Windows 7 Prof, I executeexecuting in Windows Pwershell_ISEPowershell_ISE (as administrator) the Powershell (ver. 3) commands produces expected result (of adding a domain user to local/machine Administrators group) but launching it from a script .ps1 file in folder C:\Users\myDomainUser\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup does not !?

$objGroup = [ADSI]("WinNT://myComputerName/Администраторы")'Administrators in Russian
$objUser = [ADSI]("WinNT://myDomainName/myDomainUser")
$objGroup.PSBase.Invoke("Add", $objUser.PSBase.Path)

HowWhy?
How to better add a domain user to local administrators group on Windows 7 reboot?

Why does running Powershell script line by line work, but the same in script - does not?

In Windows 7 Prof, I execute in Windows Pwershell_ISE (as administrator) Powershell (ver. 3) commands produces expected result (of adding a domain user to local/machine Administrators group) but launching it from a script .ps1 file in folder C:\Users\myDomainUser\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup does not?

$objGroup = [ADSI]("WinNT://myComputerName/Администраторы")'Administrators in Russian
$objUser = [ADSI]("WinNT://myDomainName/myDomainUser")
$objGroup.PSBase.Invoke("Add", $objUser.PSBase.Path)

How to better add a domain user to local administrators group on Windows 7 reboot?

Why does running Powershell script line by line work, but the same thru executing script file - does not?

In Windows 7 Prof, executing in Windows Powershell_ISE (as administrator) the Powershell (ver. 3) commands produces expected result (of adding a domain user to local/machine Administrators group) but launching it from a script .ps1 file in folder C:\Users\myDomainUser\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup does not !?

$objGroup = [ADSI]("WinNT://myComputerName/Администраторы")'Administrators in Russian
$objUser = [ADSI]("WinNT://myDomainName/myDomainUser")
$objGroup.PSBase.Invoke("Add", $objUser.PSBase.Path)

Why?
How to better add a domain user to local administrators group on Windows 7 reboot?

added 89 characters in body
Source Link
Fulproof
  • 101
  • 1
  • 4

In Windows 7 Prof, I execute in Windows Pwershell_ISE (as administrator) Powershell (ver. 3) commands produces expected result (of adding a domain user to local/machine Administrators group) but launching it from a script .ps1 file in folder C:\Users\myDomainUser\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup does not?

$objGroup = [ADSI]("WinNT://myComputerName/Администраторы")'Administrators in Russian
$objUser = [ADSI]("WinNT://myDomainName/myDomainUser")
$objGroup.PSBase.Invoke("Add", $objUser.PSBase.Path)

How to better add a domain user to local administrators group on Windows 7 reboot?

In Windows 7 Prof, I execute in Windows Pwershell_ISE (as administrator) Powershell (ver. 3) commands produces expected result (of adding a domain user to local/machine Administrators group) but launching it from a script .ps1 file in C:\Users\myDomainUser\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup does not?

$objGroup = [ADSI]("WinNT://myComputerName/Администраторы")'Administrators in Russian
$objUser = [ADSI]("WinNT://myDomainName/myDomainUser")
$objGroup.PSBase.Invoke("Add", $objUser.PSBase.Path)

In Windows 7 Prof, I execute in Windows Pwershell_ISE (as administrator) Powershell (ver. 3) commands produces expected result (of adding a domain user to local/machine Administrators group) but launching it from a script .ps1 file in folder C:\Users\myDomainUser\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup does not?

$objGroup = [ADSI]("WinNT://myComputerName/Администраторы")'Administrators in Russian
$objUser = [ADSI]("WinNT://myDomainName/myDomainUser")
$objGroup.PSBase.Invoke("Add", $objUser.PSBase.Path)

How to better add a domain user to local administrators group on Windows 7 reboot?

Source Link
Fulproof
  • 101
  • 1
  • 4

Why does running Powershell script line by line work, but the same in script - does not?

In Windows 7 Prof, I execute in Windows Pwershell_ISE (as administrator) Powershell (ver. 3) commands produces expected result (of adding a domain user to local/machine Administrators group) but launching it from a script .ps1 file in C:\Users\myDomainUser\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup does not?

$objGroup = [ADSI]("WinNT://myComputerName/Администраторы")'Administrators in Russian
$objUser = [ADSI]("WinNT://myDomainName/myDomainUser")
$objGroup.PSBase.Invoke("Add", $objUser.PSBase.Path)