Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The term 'System.DefaultWorkingDirectory' is not recognized as the name of a cmdlet

I am trying to generate CSV file using powershell using VSTS release job and store it to current working directory. Strange thing is the same code is working fine previously. Only difference is previously i used inline scripting but now i am using file path.

$results = @()

$data = 
@{                       
    uname = $uname             
    upass = "Apple@123"
    uid = $uid    
}

$results += New-Object PSObject -Property $data 

$results | export-csv -Path $(System.DefaultWorkingDirectory)\1UserTestDocument.csv -NoTypeInformation 

write-host "Print all files in the current directory :"
Get-Item *

error :

2019-03-01T06:56:19.2333832Z VERBOSE: Importing function 'CmdletHasMember'.
2019-03-01T06:56:19.2515776Z VERBOSE: Importing function 'Disconnect-AzureAndClearContext'.
2019-03-01T06:56:19.2515900Z VERBOSE: Importing function 'Initialize-AzModule'.
2019-03-01T06:56:19.2515985Z VERBOSE: Importing function 'Initialize-Azure'.
2019-03-01T06:56:19.2516046Z VERBOSE: Importing function 'Initialize-AzureRMModule'.
2019-03-01T06:56:19.2516153Z VERBOSE: Importing function 'Remove-EndpointSecrets'.
2019-03-01T06:56:19.2516240Z VERBOSE: Trying to disconnect from Azure and clear context at process scope
2019-03-01T06:56:19.2516312Z ##[command]Disconnect-AzureRmAccount -Scope Process -ErrorAction Stop
2019-03-01T06:56:19.7421197Z ##[command]Clear-AzureRmContext -Scope Process -ErrorAction Stop
2019-03-01T06:56:20.2546250Z ##[debug]Caught exception from task script.
2019-03-01T06:56:20.2796129Z ##[debug]Error record:
2019-03-01T06:56:20.2985848Z ##[debug]ForEach-Object : The term 'System.DefaultWorkingDirectory' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
2019-03-01T06:56:20.3038684Z ##[debug]At D:\a\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\3.1.23\AzurePowerShell.ps1:125 char:9
2019-03-01T06:56:20.3044174Z ##[debug]+         ForEach-Object {
2019-03-01T06:56:20.3217983Z ##[debug]+         ~~~~~~~~~~~~~~~~
2019-03-01T06:56:20.3218533Z ##[debug]    + CategoryInfo          : ObjectNotFound: (System.DefaultWorkingDirectory:String) [ForEach-Object], CommandNotFoun    dException
2019-03-01T06:56:20.3218704Z ##[debug]    + FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.ForEachObjectCommand

[error]The term 'System.DefaultWorkingDirectory' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

like image 569
rAJ Avatar asked Oct 30 '25 22:10

rAJ


1 Answers

you have to use $env:variable_name_with_underscores_instead_of_dots to retrieve it.

In your case its:

$env:System_DefaultWorkingDirectory
like image 131
4c74356b41 Avatar answered Nov 02 '25 12:11

4c74356b41



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!