Errors when opening Power Shell or VSC - windows

When I open Windows PowerShell or VSC it prints this message:
Invoke-Expression : At line:1 char:768
... es\Git\cmd;"C:\Users\Shawn\AppData\Local\Microsoft\WindowsApps;C:\Use ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token 'C:\Users\Shawn\AppData\Local\Microsoft\WindowsApps' in expression or statement.
At C:\Users\Shawn\anaconda3\shell\condabin\Conda.psm1:101 char:9
Invoke-Expression -Command $activateCommand;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : ParserError: (:) [Invoke-Expression], ParseException
FullyQualifiedErrorId : UnexpectedToken,Microsoft.PowerShell.Commands.InvokeExpressionCommand
How do I remedy this so that I can be sure that my system will run things correctly.

Related

Make a copy of swapfile.sys to new location [File not found error]

In PowerShell, I am trying to make a copy of the Windows swapfile (swapfile.sys)
PS C:\> Copy-Item swapfile.sys -Destination C:\Users\
However, I recieve the error:
Copy-Item : Cannot find path 'C:\swapfile.sys' because it does not exist.
At line:1 char:1
+ Copy-Item swapfile.sys -Destination C:\Users\
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\swapfile.sys:String) [Copy-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.CopyItemCommand
I can confirm the file exists with attrib *.sys
Perhaps this is due to the fact it is a hidden file, or a type of file that cannot be copied? I want to investigate this file with a HexEditor and was hoping to make a stand-alone copy for this.

cURL not recognizing command line parameters (Windows 10)

Not sure what I'm doing wrong, but any command line parameters I try to pass into curl (using double dash) are interpreted as a url.
Running curl --help:
curl : The remote name could not be resolved: '--help'
At line:1 char:1
+ curl --help
+ ~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc
eption
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
With a single dash it seems to interpret a url parameter, but it doesn't find certain parameters. Running curl -sSL:
Invoke-WebRequest : A parameter cannot be found that matches parameter name 'sSL'.
At line:1 char:6
+ curl -sSL
+ ~~~~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
Curl binary downloaded from https://curl.se/windows/
You can find the answer here: Running curl via powershell - how to construct arguments?
"In PowerShell curl is a built in alias to Invoke-WebRequest cmdlet. And aliases have priority in command resolution. To solve your problem you have more specifically, use curl.exe instead of curl, so command not resolved to alias"

AppxProvisionedPackage commands stuck on PowerShell and return DismInitialize failed

I am trying to install LOB UWP application
I used:
Add-AppxProvisionedPackage -Online -PackagePath "APPX_PATH"
-DependencyPackagePath "DEPENDENCIES"-SkipLicense
It worked for the first time, i even asked one of my colleagues to log in and the app was there.
But, after that, i tried to reinstall it with the same command. But the command refused to execute, it's just blinking and loading.
I tried other commands to get the packages or remove the package but all have the same behavior.
What could be a valid reason for that?
Get-AppXProvisionedPackage -Online | Select PackageName
Remove-AppxProvisionedPackage
-PackageName "PackageName" -Online -AllUsers
EDIT#1:I am getting the following error after waiting for long time and pressing PgDn or End buttons on keyboard.
Remove-AppxProvisionedPackage : DismInitialize failed. Error code = 0x80004005
At line:1 char:1
+ Remove-AppxProvisionedPackage -PackageName PACKAGE_NAME ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Remove-AppxProvisionedPackage], COMException
+ FullyQualifiedErrorId : Microsoft.Dism.Commands.RemoveAppxProvisionedPackageCommand

About MicrosoftTeams-TeamFunSettings

Today I found that the MicrosoftTeams powershell command Get-TeamFunSettings failed to run when the property GiphyContentRating value is "Allow all content".
Error info:
Get-TeamFunSettings : Error converting value "unknownFutureValue" to
type
'System.Nullable`1[Microsoft.TeamsCmdlets.PowerShell.Custom.Model.GiphyRatingType]'.
Path 'funSettings.giphyContentRating', line 1, position 844. At line:1
char:1
+ Get-TeamFunSettings -GroupId a3f33284-82a5-4643-a43d-401f2568177c
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-TeamFunSettings], JsonSerializationException
+ FullyQualifiedErrorId : Newtonsoft.Json.JsonSerializationException,Microsoft.TeamsCmdlets.PowerShell.Custom.GetF
unSettings
We are actively investigating this issue and a fix is expected shortly. Note this commend is in beta so instability is not unexpected.
Maybe it's just very new but according to the documentation of the command "Allow all content" is not an option. (I do think it should be one, though)
https://learn.microsoft.com/en-us/powershell/module/teams/set-teamfunsettings

Copying directory fails sometimes with "access denied"

I am executing a PowerShell script and this line:
Copy-Item -Path "$A_DIRECTORY" -Destination "$ANOTHER_DIRECTORY" -Recurse -Force
intermittently fails with the following error:
Copy-Item : Access is denied
At C:\mydir\build.ps1:224 char:5
+ Copy-Item -Path "$A_DIRECTORY" -Destination "$ANOTHER_DIRECTORY" ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Copy-Item], UnauthorizedAccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.CopyItemCommand
Now, the error message is clear, but it does not make sense because the target directory does not exist. I have write permissions and also tried to run as administrator with same result.
Why would this statement fail sometimes but not always? Perhaps it is also worth noting that $ANOTHER_DIRECTORY is deleted in the command preceding this one. The delete operation never fails.

Resources