Cant get PSCredentials to work

Hello

After spending 3/4 of the day and geting nowhere I have decided to ask here. I have a scripts which I need to run which pulls data from an anonymous share. The server hosting the share was allowing annonymous access but after being upgraded to Windows 2008 annonymous sahres are no longer allowed.

I am told that I can use PSCredentials within Powershell to authenticate against the server and then call the batch file but no matter what I cannot get this to work. There are thoughsands of questions/answers relating to this, I have tried many but they all throw up errors without exception.

I would ideally like someone to suggest a basic script which can do what I require.

I create the password using:

read-host -assecurestring | convertfrom-securestring | out-file C:\securestring.txt

And then try and run the following which throws up errors about the PSCredential assembly type cannot get loaded.

$mycred = new-object -typename System.Management.Automation.PSCredential -argumentlist "test",$pass

I know I should be able to do this in two lines from researching online but I am stumped and would appreciate some feedback.  I know there is no line about calling the batch scripts but i want to get the basic powershell command to run without errors before adding the calling script.

Thanks in advance for your help

Edit:

This is to be run on a standalone server and the file server we pull data from is on the domain. This also has to run automated as it needs to be scheduled to run every 15 minutes, hence why I need to use a method to authenticating within the script that does not need user imput so I can't use the Get-Credential command as that prompts for a login. We are creating a "service account" on the domain to use to authenticate to the domain joined server we pull the data from.


June 30th, 2015 2:26pm

I forgot to mention, this is to be run on a standalone server and the file server we pull data from is on the domain. This also has to run automated as it needs to be scheduled to run every 15 minutes, hence why I need to use a method to authenticating within the script that does not need user imput so I can't use the Get-Credential command as that prompts for a login. We are creating a "service account" on the domain to use to authenticate against the server.

Thanks and apologies for not mentioning this in the initial post.

Free Windows Admin Tool Kit Click here and download it now
July 1st, 2015 3:59am

You must enable and configure CredSSP on the remote server.  All other items I posted must also be true.

Once you can manually access the remote server then you can use the embedded credentials however, you must be very careful to not expose a plain text password.  I highly recommend against what you are doing as it is a very insecure approach to administration.  Please consider learning how to locally administer a system.  Your process should be scheduled on the target system.

July 1st, 2015 8:01am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics