I am new to powershell so would need need to resolve this issue.
We are trying to execute a powershell script via Azure devops pipelines and the script is made to access a network shared drive to identify a particular file.
The script runs perfectly fine in the gui session and is able to get the file.
However when we run it from AZ pipelines, it fails stating the access is denied.
The user being used in AZ Pipelines has admin access over the file.
The N/w drive path looks something like this.
\\ServerName\builds\PACKAGES\MainMasterBuildDrop\MainScheduledBuild\axmodel
Code ::
$locr = "\\ServerName\builds\PACKAGES\MainMasterBuildDrop\MainScheduledBuild\axmodel"
$axfiler = Get-ChildItem -Path $locr | Select FullName | ft -hidetableheaders | Out-String
$filever = $($($axfiler.split("\")[-1]).Split("_")[-1]).Replace(".axmodel", "")
Error ::
2022-01-14T07:19:22.6339088Z o -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'C:\User
2022-01-14T07:19:22.6339869Z s\SRV_Deployment\AppData\Local\Temp\61e3d867-9d07-41cc-91c1-c4a04717bc2d
2022-01-14T07:19:22.6340311Z .ps1'"
2022-01-14T07:19:22.6340436Z
2022-01-14T07:19:22.7446332Z ls : Access is denied
2022-01-14T07:19:22.7446823Z At line:1 char:1
2022-01-14T07:19:22.7447184Z + & 'C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe' -NoLogo ...
2022-01-14T07:19:22.7447867Z + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2022-01-14T07:19:22.7448434Z + CategoryInfo : NotSpecified: (ls : Access is denied:String) [],
2022-01-14T07:19:22.7448858Z RemoteException
2022-01-14T07:19:22.7449188Z + FullyQualifiedErrorId : NativeCommandError
2022-01-14T07:19:22.7449545Z
2022-01-14T07:19:22.7449643Z
2022-01-14T07:19:22.7618724Z At E:\DeploymentTeam\Scripts\DeploymentValidation\Test.ps1:1 char:1
2022-01-14T07:19:22.7619629Z + ls "\\Server\builds\PACKAGES\MainMasterBuildDrop\ ...
2022-01-14T07:19:22.7620370Z + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2022-01-14T07:19:22.7620732Z
2022-01-14T07:19:22.7620874Z
2022-01-14T07:19:22.7731192Z + CategoryInfo : PermissionDenied: (\\ServerName\...edBuild\axmo
2022-01-14T07:19:22.7731830Z del:String) [Get-ChildItem], Unauthoriz
2022-01-14T07:19:22.7732125Z
2022-01-14T07:19:22.7732299Z
2022-01-14T07:19:22.7845365Z edAccessException
2022-01-14T07:19:22.7845602Z
2022-01-14T07:19:22.7846744Z
2022-01-14T07:19:22.7966282Z + FullyQualifiedErrorId : ItemExistsUnauthorizedAccessError,Microsoft.Power
2022-01-14T07:19:22.7966826Z Shell.Commands.GetChildItemCommand
2022-01-14T07:19:22.7966978Z
2022-01-14T07:19:22.7967080Z
Related
I am very new to Jenkins. I have installed it locally on my Windows 10, with no slaves, only the master agent.
Then I created the following declarative pipeline:
pipeline {
agent any
stages {
stage('Stage 1: Running TSextract') {
steps {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
powershell 'Start-Process -FilePath E:\\my-config\\bin2\\RemoteRunner.exe -ArgumentList "dummy.azurecr.io/my-extract:1.10.13 E:\\my-config test-79 -t td TSextract"'
}
}
}
}
}
When I run this command in PowerShell from the command line everything happens as it should: Start-Process -FilePath E:\my-config\bin2\RemoteRunner.exe -ArgumentList "dummy.azurecr.io/my-extract:1.10.13 E:\my-config test-79 -t td TSextract"
However, through Jenkins, via the above descriptive pipeline, this results in the following error:
powershell.exe : Start-Process : This command cannot be run due to the error: Access is denied.
At C:\windows\system32\config\systemprofile\AppData\Local\Jenkins\.jenkins\workspace\LocalPipeline#tmp\durable-eb81f70f\powershellWrapper.ps1:3 char:1
+ & powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Comm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Start-Process :...cess is denied. :String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
At C:\windows\system32\config\systemprofile\AppData\Local\Jenkins\.jenkins\work
space\LocalPipeline#tmp\durable-eb81f70f\powershellScript.ps1:1 char:1
+ Start-Process -FilePath E:\my-config\bin2\RemoteRunner.exe -Argument ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOp
erationException
+ FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
ommands.StartProcessCommand
So the question is what/ how exactly do I grant permissions to Start-Process from Jenkins?
Total newbie here...
I am attempting to execute a ps1 file using Powershell and receiving an error. What does this error mean? I'm concerned that OneDrive is causing an issue with the path.
Running this ps1 file by opening powershell and entering:
PowerShell -executionpolicy Bypass -NoExit C:\Users\Terry\OneDrive\desktop\WindowsPull.ps1
This is the file:
$segmentFolders = Get-ChildItem | where {$_.Attributes -eq 'Directory'}
Error:
Set-Location : Cannot process argument because the value of argument "path" is null. Change the value of argument
"path" to a non-null value.
At C:\Users\Terry\OneDrive\desktop\WindowsPull.ps1:4 char:1
+ Set-Location $videoDir.FullName
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-Location], PSArgumentNullException
+ FullyQualifiedErrorId : ArgumentNull,Microsoft.PowerShell.Commands.SetLocationCommand
I execute two Powershell scripts during a installation process from a desktop application under Windows 10 IoT Enterprise.
%WINDIR%\System32\WindowsPowerShell\v1.0\PowerShell.exe -ExecutionPolicy Bypass -File ".\KeyboardFilter.ps1"
%WINDIR%\System32\WindowsPowerShell\v1.0\PowerShell.exe -ExecutionPolicy Bypass -File ".\ShellLauncher.ps1"
But the execution of the Powershell scripts is not successful. I get the following errors:
Get-WMIObject : Provider load failure
At C:\Program Files\Application\KeyboardFilter.ps1:31 char:19
+ ... $predefined = Get-WMIObject -class WEKF_PredefinedKey #CommonParams |
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], ManagementException
+ FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
Write-Error : A positional parameter cannot be found that accepts argument 'is'.
At C:\Program Files\Application\KeyboardFilter.ps1:41 char:9
+ Write-Error $Id is not a valid predefined key
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Write-Error], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.WriteErrorCommand
enable-windowsoptionalfeature : An attempt was made to load a program with an incorrect format.
At C:\Program Files\Application\ShellLauncher.ps1:4 char:1
+ enable-windowsoptionalfeature -online -featureName Client-EmbeddedShe ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Enable-WindowsOptionalFeature], COMException
+ FullyQualifiedErrorId : Microsoft.Dism.Commands.EnableWindowsOptionalFeatureCommand
The installation process starts with administration permissions.
The first script adds key combinations to the Keyboard Filter (Windows 10 IoT feature).
The second scripts enable and configure the Shell Launcher (also Windows 10 IoT feature).
KeyboardFilter.ps1:
param (
[String] $ComputerName
)
$CommonParams = #{"namespace"="root\standardcimv2\embedded"}
$CommonParams += $PSBoundParameters
function Enable-Predefined-Key($Id) {
$predefined = Get-WMIObject -class WEKF_PredefinedKey #CommonParams |
where {
$_.Id -eq "$Id"
};
if ($predefined) {
$predefined.Enabled = 1;
$predefined.Put() | Out-Null;
Write-Host Enabled $Id
} else {
Write-Error $Id is not a valid predefined key
}
}
If I execute the Powershell scripts in a batchfile or on Powershell console, everything works fine. I also tried to execute the Powershell scripts during the installation process with Powershell x86 and x64, same errors in both cases.
Any hints, tips or solution for this problem?
I've added the following line of Powershell codes in Jenkins and it's throwing some errors, although it's working fine when I'm trying to execute it via Powershell ISE on the same desktop/machine.
I have configured the Jenkins service logon and the user ID got correct permission.
Kindly advise.
servers = Get-Content "C:\tmp\script\updated\SessionHost.txt"
foreach ($server in $servers)
{
$FolderWindows = Start-Process -FilePath "\\$server\C$\Temp" -WindowStyle Maximized
}
Error Message on Jenkins:
Start-Process : This command cannot be run due to the error: Server execution
failed.At C:\tmp\script\updated\MainTaiwanUAT.ps1:385 char:22
+ $FolderWindows = Start-Process -FilePath "\\$server\C$\Temp"
-WindowS ...
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOp
erationException
+ FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
ommands.StartProcessCommand
I was trying to make a dummy diagnostics worker role using the following article
When i run the following command in step 4 :
(Get-AzureServiceAvailableExtension -ExtensionName 'PaaSDiagnostics' -ProviderNamespace 'Microsoft.Azure.Diagnostics').PublicConfigurationSchema | Out-File -Encoding utf8 -FilePath 'WadConfig.xsd'
I get the following error in azure powershell, we need the subscription in this command but not sure where.
Also, is there a place where I can find how to make a dummy diagnostics worker role.
VERBOSE: 3:32:14 PM - Begin Operation: Get-AzureServiceAvailableExtension
Get-AzureServiceAvailableExtension : No default subscription has been designated. Use Select-AzureSubscription
-Default <subscriptionName> to set the default subscription.
At line:1 char:2
+ (Get-AzureServiceAvailableExtension -ExtensionName 'PaaSDiagnostics' -ProviderNa ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-AzureServiceAvailableExtension], ApplicationException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.Extensions.GetAzureServiceAvailableExt
ensionCommand
VERBOSE: 3:32:14 PM - Completed Operation: Get-AzureServiceAvailableExtension
Out-File : Access to the path 'C:\WadConfig.xsd' is denied.
At line:1 char:148
+ ... rationSchema | Out-File -Encoding utf8 -FilePath 'WadConfig.xsd'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (:) [Out-File], UnauthorizedAccessException
+ FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand
First add your credentials using:
add-azureaccount
Next, select desired subscription (if you have more than one) using:
Select-AzureSubscription -SubscriptionId <id>
Finally, try again.