Get-Content : Cannot find path

312 views
Skip to first unread message

aaron.t...@total.care

unread,
Nov 30, 2016, 6:39:15 PM11/30/16
to Jenkins Users
$FilePath = 'C:\Windows\System32\inetsrv\config\applicationHost.config'
$Line2Edit = '<section name="httpLogging" overrideModeDefault="Deny" />'
$AppendAllow =  '<section name="httpLogging" overrideModeDefault="Allow" />' 
 
(Get-Content -Path  $FilePath) -replace $Line2Edit , "$AppendAllow" |
Set-Content $FilePath

Just as the title states, Jenkins cannot find the desired path.  Yes, the path exists, yes i have checked to make sure.  

When i run the the PowerShell script local it runs just fine, which leads me to believe its a permission issue, but Jenkins has admin rights and should be able to make any changes necessary.

PowerShell runs 64 bit,  not sure about Jenkins however...

Anybody have any suggestions?

niristotle okram

unread,
Nov 30, 2016, 8:19:51 PM11/30/16
to jenkins...@googlegroups.com
More info needed. Is this executed as a powershell script via jenkins or  via the pipeline script or executed as a batch command (but feeding a powershell code)?
What does the console error look like? 

 


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/df81ec10-6f58-478c-a0f4-8fe4a43c4eb0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Regards
nirish okram

aaron.t...@total.care

unread,
Dec 1, 2016, 9:32:32 AM12/1/16
to Jenkins Users

This is ran as a PowerShell exectued by Jenkins.  I have attached the console output for reference

.


On Wednesday, November 30, 2016 at 6:19:51 PM UTC-7, ok999 wrote:
More info needed. Is this executed as a powershell script via jenkins or  via the pipeline script or executed as a batch command (but feeding a powershell code)?
What does the console error look like? 

 

On Wed, Nov 30, 2016 at 6:39 PM, <aaron.t...@total.care> wrote:
$FilePath = 'C:\Windows\System32\inetsrv\config\applicationHost.config'
$Line2Edit = '<section name="httpLogging" overrideModeDefault="Deny" />'
$AppendAllow =  '<section name="httpLogging" overrideModeDefault="Allow" />' 
 
(Get-Content -Path  $FilePath) -replace $Line2Edit , "$AppendAllow" |
Set-Content $FilePath

Just as the title states, Jenkins cannot find the desired path.  Yes, the path exists, yes i have checked to make sure.  

When i run the the PowerShell script local it runs just fine, which leads me to believe its a permission issue, but Jenkins has admin rights and should be able to make any changes necessary.

PowerShell runs 64 bit,  not sure about Jenkins however...

Anybody have any suggestions?

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.



--
Regards
nirish okram

aaron.t...@total.care

unread,
Dec 2, 2016, 2:59:12 PM12/2/16
to Jenkins Users
Bump

Joel Reed

unread,
Dec 2, 2016, 6:34:42 PM12/2/16
to Jenkins Users
There might be a couple possible explanations here. First and my guess at most likely cause is that "you" (meaning the Jenkins slave agent executing your code) does not have read access to your applicationHost.config and/or the config parent directory. In my fairly default environments only SYSTEM and Administrators have access to this directory/file structure. You may need to figure out what user your agent is executing the code as. The most definitive way may be to call the whoami.exe from within your code, check the console output.

Secondly you may need to check your Jenkins job configuration and make sure that your code is running on the correct slave agent, the one with IIS installed. If its running on a host without IIS installed that file and directory structure won't exist and that would be a valid error. Execute something like hostname.exe or do a Get-ChildItem -Path C:\Windows\System32\inetsrv\config ( or C:\Windows\System32\inetsrv) and check the console for what gets output. Good luck.
Reply all
Reply to author
Forward
0 new messages