I have a long Powershell script that "builds" a PC for me, by adding everything I need to a Windows 7 (32 bit) PC. I have had this script for several years and it has worked fine. One of the first things I do is change the password. This line of code suddenly doesn't work in the script -
([adsi]"WinNT://ccm2756/Administrator").SetPassword("NewPassword")
I get "the following exception has occurred while retrieving member SetPassword. Network path not found."
Has worked just fine all this time. And on the same PCs. Haven't changed the script, haven't changed the PCs (I've burned the images back to saved based operating systems). Suddenly, I am getting this error? And yet, if I open a command line and type "Powershell" to get to a PS Command line and run that exact same command, it goes through without any errors.
What am I missing here?
Related
I've been banging my head against a powershell shaped wall all day. For work reasons, I want to be able to upload a file from a windows machine to a remote linux box. There's some work to do before so I foolishly believed I could just drop in a call to SCP in my script. But it doesn't like it one bit:
Putting
scp api.zip ${user}#${currEnv}:/${uploadLocation}
where user is the remote login name, currEnv is the ip address and uploadLocation is /tmp (at least while I'm debugging)
in the code just causes the execution to hang completely - in fact the same thing happens if I run that command from the PS command line, even if I manually replace all the variables.
I tried replacing it with pscp which works better in that it actually connects, but then throws up the usual warning about this being the first time I've connected and should type 'y' to proceed (again, even from the command line iteself) - but that won't let me type anything in. I've also even tried using wsl scp ... to run it (don't tell the IT guy), but that also seems to hang - it shows me the server banner, but never gets to the bit where it should be asking for my remote password.
Am I missing something?
Whenever I open Windows Powershell I see this
powershell error message. It seems to me that every time I open Powershell it attempts to run conda.exe from a TEMP folder that no longer exists on my machine. Furthermore, when I open command prompt I see this error, so I'm guessing it's doing the same thing there.
I've checked my user and system path variables and there is no mention of the temp path that is listed in the powershell error. Any help with this would be greatly appreciated!
When such a thing happens, it's most likely because of your PowerShell $Profile, that is always loaded on startup.
Check the file, see if it exists and what's inside it. If you still got issues after that, let us know.
I've had a startup script which sets my default settings as well as defines my working directory and adds all relevant paths. In this script, there is the command
addpath(genpath(pwd))
which simply adds all of the subfolders within my current directory.
Recently I got a new SSD and tried to move most of my non-program files over to it. Both drives work fine and are able to communicate smoothly. However, now I notice that if I try to call the command twice, the first command executes in less than a second whereas the second command continues to execute (20+ minutes and still running).
I am fairly certain I did not have this problem before and it occurs if a single file in the addpath is already on MATLABPATH. Furthermore, adding the files to the permanent MATLABPATH and restarting MATLAB also results in a soft error (runs forever without any actual error). This error persists for paths on both drives but the only change is that I got a new drive.
Edit: It appears to be getting stuck on line 94 of "addpath"
path(p, mp);
I am using Windows 10 on MATLAB 2017b.
Thank you for your help
When I run powershell ISE, I can execute commands/scripts without issue. When I launch either the 32 or 64 bit command line, the window takes about 30 seconds to load and then it is frozen. It will not accept inputs of any kind (keyboard or copy/paste). I have tried doing a system check, no errors. I even tried updating to powershell 4.0, the install was successful but the command line still locks on launch. Can anyone advise how to fix this? I am using windows server 2008 R2.
Update
It appears that the powershell is in fact accepting input, except at a glacial speed. I left the window open while I was writing this post initially, and then grabbed a coffee. Upon my return I found that what I have tried to copy/paste and type was now in the powershell command line. I have now attempted to execute $PSVersionTable.PSVersion, and going on 3 minutes now I still have no response. My guess is it will come back at some point but this is obviously not acceptable. Any ideas on how to debug/fix this?
Update2
As far as I can tell all the locations listed in $PROFILE | Select * don't exist. I also tried launching: powershell.exe -noprofile, but this did not help
After reading this post I decided to try that tool and see if I had a similar problem and discovered that there were literally hundreds of writes per second happening when powershell command line was running and they were all to the FusionLog. Disabling the Fusion logging fixed the issue completely (this was enabled a while ago to debug a different issue with an app and I must have forgotten to disable it). Everything else on the machine seemed to hum along just fine with FusionLogging in the background but powershell was horribly crippled. Hope this helps someone some day.
Evening,
I have recently installed TFS2015 and investigating the Release Management integrated solution, but have come across a huge blocker that I just cannot make sense of.
I currently have a RM2013 build working with TFS, RM Server 2013, and Powershell DSC and have setup a new deployment in RM2015, it has a single task in it 'Execute Powershell on Remote Machine' - with a very simple powershell script just writing out a string to the verbose listener.
I have verified that the file is transferred to the Agent working directory as part of the artifact transfer process, and if I call Import-Module "path to script" (Which is what the PowerShellonTargetMachines script seems to do under the hood) in the ISE of the remote server, my script runs perfectly fine - but no matter what I do, in TFS release 2015 I get this error without fail:
[error]The term 'path to script\test.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. For more info please refer to http://aka.ms/powershellontargetmachinesreadme
Now just to double confirm, the path to the scrpt is 100% correct, I have pasted it into a local ISE on the remote server, and it executes perfectly fine - but from TFS2015 Execute Powershell on Remote Server - it simply fails to run, in fact any script I point at fails to run with the exact same error (I initially thought it might be a DSC component install failure, but even with a simple test script the same issue occurs without fail!
My path in the tasks Deployment>Powershell Script parameter input is:
c:\test_scripts\test.ps1
I have tried with quotes, without quotes, dot sourcing - nothing makes a difference which is making me think something fundamentally is either broken with my installation, or I am simply doing this wrong.
Any ideas gratefully received!!!
The script has to already be on the machine. You can push the script using the "Windows Machine File Copy" task.
Fixed this... make sure you execute the PS1 file on the release agent itself unless copying the powershell files to the remote node via file copy first as indicated below