Hi All,I have a basic script that gets a list of pc's from a
txt file then connects to each one of them and then searches an .ini
file for a specific word, my problem is that it needs an admin account
to connect to the list of pc's c: drives, i have the $credential at the
begining of my code and it does ask for it but it still does not seem
to use it to connect to the list of pc's, ca anyone help?Error
i get back: Cannot find path 'CJ058694c$Program FilesCommon
Filestest test SysAdminConfiggo.ini' because it does not exist.# used to cach cred.$credential = $nullif(Test-Path Variable:Lee.Holmes.CommonScript.CachedCredential){$credential = ${GLOBAL:Lee.Holmes.CommonScript.CachedCredential}}${GLOBAL:Lee.Holmes.CommonScript.CachedCredential} =Get-Credential $credential$credential = ${GLOBAL:Lee.Holmes.CommonScript.CachedCredential}$pathtopclist = Read-Host "Enter Full Path to PC List"$arrComputers = Get-Content -Path "$pathtopclist"$searchinput = Read-Host "Please Enter Your Search Word"foreach ($strComputer in $arrComputers){$credential$matches = Select-String -Simple "$searchinput" "$strComputerc$Program FilesCommon Filestest test SysAdminConfiggo.ini" $matches | select line,path | Format-List >> c:testgoini.csv }
$credential to map to remote pc c: drives
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
$credential to map to remote pc c: drives
Hi All,I have a basic script that gets a list of pc's from a
txt file then connects to each one of them and then searches an .ini
file for a specific word, my problem is that it needs an admin account
to connect to the list of pc's c: drives, i have the $credential at the
begining of my code and it does ask for it but it still does not seem
to use it to connect to the list of pc's, ca anyone help?Error
i get back: Cannot find path 'CJ058694c$Program FilesCommon
Filestest test SysAdminConfiggo.ini' because it does not exist.# used to cach cred.$credential = $nullif(Test-Path Variable:Lee.Holmes.CommonScript.CachedCredential){$credential = ${GLOBAL:Lee.Holmes.CommonScript.CachedCredential}}${GLOBAL:Lee.Holmes.CommonScript.CachedCredential} =Get-Credential $credential$credential = ${GLOBAL:Lee.Holmes.CommonScript.CachedCredential}$pathtopclist = Read-Host "Enter Full Path to PC List"$arrComputers = Get-Content -Path "$pathtopclist"$searchinput = Read-Host "Please Enter Your Search Word"foreach ($strComputer in $arrComputers){$credential$matches = Select-String -Simple "$searchinput" "$strComputerc$Program FilesCommon Filestest test SysAdminConfiggo.ini" $matches | select line,path | Format-List >> c:testgoini.csv }
txt file then connects to each one of them and then searches an .ini
file for a specific word, my problem is that it needs an admin account
to connect to the list of pc's c: drives, i have the $credential at the
begining of my code and it does ask for it but it still does not seem
to use it to connect to the list of pc's, ca anyone help?Error
i get back: Cannot find path 'CJ058694c$Program FilesCommon
Filestest test SysAdminConfiggo.ini' because it does not exist.# used to cach cred.$credential = $nullif(Test-Path Variable:Lee.Holmes.CommonScript.CachedCredential){$credential = ${GLOBAL:Lee.Holmes.CommonScript.CachedCredential}}${GLOBAL:Lee.Holmes.CommonScript.CachedCredential} =Get-Credential $credential$credential = ${GLOBAL:Lee.Holmes.CommonScript.CachedCredential}$pathtopclist = Read-Host "Enter Full Path to PC List"$arrComputers = Get-Content -Path "$pathtopclist"$searchinput = Read-Host "Please Enter Your Search Word"foreach ($strComputer in $arrComputers){$credential$matches = Select-String -Simple "$searchinput" "$strComputerc$Program FilesCommon Filestest test SysAdminConfiggo.ini" $matches | select line,path | Format-List >> c:testgoini.csv }
$credential to map to remote pc c: drives
If you don't have admin rights,which it sounds like you don't, then you need to create an authenticated connection. New-PSDrive looks like it would work, but the -credential parameter was not implemented in v1. You could map a drive with the NET USE command, but you would need the username and password.If the path to the file is the same on all machines, then you could use WMI and CIM_DATAFILE class. Get-WMIObject does support the use of alternate credentials. I don't know how you could grab the contents though.But the major item is that you may be mistaken about what a PScredential does. When you do this:$cred=get-credential$cred is just a stored credential. It does not authenticate you or verify you even typed in the right password. It's not until you do something like this:get-wmiobject win32_bios -comp ABC123 -credential $credThat the credential is passed to the security subsystem and you are then authenticated. Right now, you aren't using the credential to authenticate to the remote machine. Nor can I think of an easy way.Is it the same credential for all machines? If so, can you simply start your PowerShell session using RUNAS and use the alternate credential?By the way, this line$credential=get-credentialis caching the credential. Not sure why you are going through all the hoops with the global variable. If you need that, simply create $credential in your Profile script and then it will always be available.Is the ini file hidden or have any special ACL on it?
$credential to map to remote pc c: drives
You still need a credential to establish a new PSSession on the remote computer. You could then execute your command as if you were on that machine. You could do it interactively or set it up as a background job and get results later.PowerShell v2.0 would have to be installed locally and on remote machines. The remote functionality is only supported right now on Vista, 2008 and Windows7.I take it running PowerShell with different credentials didn't work?
$credential to map to remote pc c: drives
If you are packaging a PowerShell script, then PowerShell must be installed whereever you are going to run the exe. So if you give the exe to a user to run, they must have Powershell installed and configured to run scripts on their desktop.
$credential to map to remote pc c: drives
Unfortunately, if you are having issues with a feature in PrimalScript, you'll need to post in the SAPIEN support forums so the support guys see it. They won't see your problem here. What you could do though, is post the script you are packaging so we can make sure it works the way you expect.
$credential to map to remote pc c: drives
Make sure you specified alternate credentials when packaging in the form domainusername.
$credential to map to remote pc c: drives
I was wrong. It should be domain@username. You'll have to post your problem with all the details in the SAPIEN support forum.