After setting up a on prem developer environment, I was ready do start coding add-ins. But then i got access denied, What I'm running as administrator I'm king and can access everything. After after some searching on the net I found the answer (I do not remember the link). The fact that I was running as an System Account was the problem, it is not allowed. Guess I'm not king as administrator after-all. Created a other user and tried one more time, bang it worked.
Today I needed to call another script file in the same folder as the main script. After a little searching on the web I found "$MyInvocation.MyCommand.Path". "$MyInvocation.MyCommand.Path" returns the path to the current script, With that I was able to get the current folder using Get-Item. This is my test scripts: ToRun.ps1: Write-Host $MyInvocation.MyCommand.Path $scriptDirectory = (Get-Item $MyInvocation.MyCommand.Path).DirectoryName $scriptName = "HelloWorld.ps1" Write-Host calling $scriptName in $scriptDirectory & ($scriptDirectory + '\' + $scriptName) HelloWorld.ps1: Write-Host "Hello word" After running the script the output was: calling HelloWorld.ps1 in C:\scriptFun Hello word Simple but useful.
Comments