"global" variable


i have variable :
$x="";
function setx(){
$x=10;
}
setx
write-host $x
it seems value updated in setx local function , not script, how can modify the 
script variavle?
and there option explicit in vbscript?

hi,

try use global scope:

  new-variable -scope global -name x -value ""   function setx(){   $global:x=10;   }   setx    write-host $x  



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

CRL Revocation always failed

Failed to query the results of bpa xpath

0x300000d errors in Microsoft Remote Desktop client