Jim Metcalf
asked on
adding credentials to a powershell command
I am trying to delete some files on a network share. I need to add different credentials in the script of an administrator to finish the command.
can I get the exact syntax of the powershell command if these are my variables.
these are made up examples of variables....
server unc path
\\apples\stems\*.*
domain = trees
username = moon
pwd = rock
I want to delete all files within the directory of \\apples\stems
also for bonus points... if you could tell me how to delete all the files in that directory that are over 14 days old
so two scripts requested.
Thanks!
can I get the exact syntax of the powershell command if these are my variables.
these are made up examples of variables....
server unc path
\\apples\stems\*.*
domain = trees
username = moon
pwd = rock
I want to delete all files within the directory of \\apples\stems
also for bonus points... if you could tell me how to delete all the files in that directory that are over 14 days old
so two scripts requested.
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The admin should have access to that folder, so why changing identity? It is difficult to connect to a share with a different user if there is a connection to any share on that server from this session, so it is something to avoid.