troubleshooting PS Script


hi all,

last week, helped me ps script adds values remote servers registry, reason after couple of days script stopped working, , i'm getting error messages.

the script wallst360 suggested me this.

$srvs = get-content yourserverlist.txt

 foreach ($srv in $srvs) {
 $reg = [microsoft.win32.registrykey]::openremotebasekey('localmachine', $srv)
 $regkey = $reg.opensubkey("software\\microsoft",$true)
 $regkey.setvalue("migdal_servers", "prd")

}

 

and worked great, mentioned, when add servers txt file, , running script again i'm getting error:

==============================================

exception calling "opensubkey" "2" argument(s): "requested registry access
 is not allowed."
@ c:\scomtest\srvlist.ps1:5 char:27
+  $regkey = $reg.opensubkey <<<< ("software\\microsoft",$true)
    + categoryinfo          : notspecified: (:) [], methodinvocationexception
    + fullyqualifiederrorid : dotnetmethodexception

you cannot call method on null-valued expression.
@ c:\scomtest\srvlist.ps1:6 char:18
+  $regkey.setvalue <<<< ("migdal_servers", "prd")
    + categoryinfo          : invalidoperation: (setvalue:string) [], runtimee
   xception
    + fullyqualifiederrorid : invokemethodonnull

exception calling "opensubkey" "2" argument(s): "requested registry access
 is not allowed."
@ c:\scomtest\srvlist.ps1:5 char:27
+  $regkey = $reg.opensubkey <<<< ("software\\microsoft",$true)
    + categoryinfo          : notspecified: (:) [], methodinvocationexception
    + fullyqualifiederrorid : dotnetmethodexception

you cannot call method on null-valued expression.
@ c:\scomtest\srvlist.ps1:6 char:18
+  $regkey.setvalue <<<< ("migdal_servers", "prd")
    + categoryinfo          : invalidoperation: (setvalue:string) [], runtimee
   xception
    + fullyqualifiederrorid : invokemethodonnull

exception calling "opensubkey" "2" argument(s): "requested registry access
 is not allowed."
@ c:\scomtest\srvlist.ps1:5 char:27
+  $regkey = $reg.opensubkey <<<< ("software\\microsoft",$true)
    + categoryinfo          : notspecified: (:) [], methodinvocationexception
    + fullyqualifiederrorid : dotnetmethodexception

you cannot call method on null-valued expression.
@ c:\scomtest\srvlist.ps1:6 char:18
+  $regkey.setvalue <<<< ("migdal_servers", "prd")
    + categoryinfo          : invalidoperation: (setvalue:string) [], runtimee
   xception
    + fullyqualifiederrorid : invokemethodonnull

exception calling "opensubkey" "2" argument(s): "requested registry access
 is not allowed."
@ c:\scomtest\srvlist.ps1:5 char:27
+  $regkey = $reg.opensubkey <<<< ("software\\microsoft",$true)
    + categoryinfo          : notspecified: (:) [], methodinvocationexception
    + fullyqualifiederrorid : dotnetmethodexception

you cannot call method on null-valued expression.
@ c:\scomtest\srvlist.ps1:6 char:18
+  $regkey.setvalue <<<< ("migdal_servers", "prd")
    + categoryinfo          : invalidoperation: (setvalue:string) [], runtimee
   xception
    + fullyqualifiederrorid : invokemethodonnull

exception calling "opensubkey" "2" argument(s): "requested registry access
 is not allowed."
@ c:\scomtest\srvlist.ps1:5 char:27
+  $regkey = $reg.opensubkey <<<< ("software\\microsoft",$true)
    + categoryinfo          : notspecified: (:) [], methodinvocationexception
    + fullyqualifiederrorid : dotnetmethodexception

you cannot call method on null-valued expression.
@ c:\scomtest\srvlist.ps1:6 char:18
+  $regkey.setvalue <<<< ("migdal_servers", "prd")
    + categoryinfo          : invalidoperation: (setvalue:string) [], runtimee
   xception
    + fullyqualifiederrorid : invokemethodonnull

exception calling "opensubkey" "2" argument(s): "requested registry access
 is not allowed."
@ c:\scomtest\srvlist.ps1:5 char:27
+  $regkey = $reg.opensubkey <<<< ("software\\microsoft",$true)
    + categoryinfo          : notspecified: (:) [], methodinvocationexception
    + fullyqualifiederrorid : dotnetmethodexception

you cannot call method on null-valued expression.
@ c:\scomtest\srvlist.ps1:6 char:18
+  $regkey.setvalue <<<< ("migdal_servers", "prd")
    + categoryinfo          : invalidoperation: (setvalue:string) [], runtimee
   xception
    + fullyqualifiederrorid : invokemethodonnull

exception calling "opensubkey" "2" argument(s): "requested registry access
 is not allowed."
@ c:\scomtest\srvlist.ps1:5 char:27
+  $regkey = $reg.opensubkey <<<< ("software\\microsoft",$true)
    + categoryinfo          : notspecified: (:) [], methodinvocationexception
    + fullyqualifiederrorid : dotnetmethodexception

you cannot call method on null-valued expression.
@ c:\scomtest\srvlist.ps1:6 char:18
+  $regkey.setvalue <<<< ("migdal_servers", "prd")
    + categoryinfo          : invalidoperation: (setvalue:string) [], runtimee
   xception
    + fullyqualifiederrorid : invokemethodonnull

exception calling "opensubkey" "2" argument(s): "requested registry access
 is not allowed."
@ c:\scomtest\srvlist.ps1:5 char:27
+  $regkey = $reg.opensubkey <<<< ("software\\microsoft",$true)
    + categoryinfo          : notspecified: (:) [], methodinvocationexception
    + fullyqualifiederrorid : dotnetmethodexception

you cannot call method on null-valued expression.
@ c:\scomtest\srvlist.ps1:6 char:18
+  $regkey.setvalue <<<< ("migdal_servers", "prd")
    + categoryinfo          : invalidoperation: (setvalue:string) [], runtimee
   xception
    + fullyqualifiederrorid : invokemethodonnull

exception calling "opensubkey" "2" argument(s): "requested registry access
 is not allowed."
@ c:\scomtest\srvlist.ps1:5 char:27
+  $regkey = $reg.opensubkey <<<< ("software\\microsoft",$true)
    + categoryinfo          : notspecified: (:) [], methodinvocationexception
    + fullyqualifiederrorid : dotnetmethodexception

you cannot call method on null-valued expression.
@ c:\scomtest\srvlist.ps1:6 char:18
+  $regkey.setvalue <<<< ("migdal_servers", "prd")
    + categoryinfo          : invalidoperation: (setvalue:string) [], runtimee
   xception
    + fullyqualifiederrorid : invokemethodonnull

 

please advise why error, did not make changes script.

hope hear asap.

best regards,

nahum.

 

hi guys,

just wanted let know, solved problem.

i ran script domain admin priviliges , worked.

best regards,

nahum



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

some help on Event 540

WMI Repository 4GB limit - Win 2003 Ent Question

Event ID 1302 (error 1307) DFS replication service encountered an error while writing to the debug log file