Oh My Posh seems to randomly throw an exception and does not load the cli - windows-10

For some reason, OMP will throw this error, seemingly randomly, and will not load the input line.
It happens in VSC and VSCodium, as far as I have noticed.
Restarting the programs or opening a new terminal does not help, it just shows the error below again and again.
If I leave the console open it also spams a new line infinitely. SMH...
Then, suddenly, as randomly as it seems to happen, everything works again.
Usually after a few minutes, which is pretty annoying if I need the terminal right there and then.
I am using a custom local config for OMP.
Any advice about what to even check would be appreciated.
Set-PSReadLineOption : The type initializer for 'Microsoft.PowerShell.PSConsoleReadLine' threw an exception.
At line:381 char:5
+ Set-PSReadLineOption -ContinuationPrompt (#(Start-Utf8Process $sc ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-PSReadLineOption], TypeInitializationException
+ FullyQualifiedErrorId : System.TypeInitializationException,Microsoft.PowerShell.SetPSReadLineOption

Related

I get this error when I run a .py file in vs code, it says something is not recognized , can anyone help me to fix that?

I get this error when I run a .py file in vs code:
n38-32" "c:/Users/hassan kh/Desktop/MY FOLDER/Python Projects/1_1.py"
& : The term 'C:/Users/hassan kh/AppData/Local/Programs/Python/Python38-32' 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.
At line:1 char:3
+ & "C:/Users/hassan kh/AppData/Local/Programs/Python/Python38-32" "c:/Users/hassa ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:/Users/hassan...hon/Python38-32:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I deleted Python and vs code and installed it again but I get this error yet. if anyone knows or had this problem before, please let me know how can I fix it?
Isn't the path should be with backward slash \ in the path.

Register-ServiceFabricApplicationType on a secure cluster always times out

When this command is executed while connected to a secure cluster:
Register-ServiceFabricApplicationType -ApplicationPathInImageStore 'MyType' -TimeoutSec 600 -Debug -Verbose
...it throws a timeout exception. I can run Copy-ServiceFabricApplicationPackage without problems, so it's clearly possible to connect to the cluster.
Registering an app type shouldn't really be a heavy operation, I therefore suspect that there is some underlying problem.
Stack trace:
VERBOSE: System.TimeoutException: Operation timed out. ---> System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x80071BFF
at System.Fabric.Interop.NativeClient.IFabricApplicationManagementClient6.EndProvisionApplicationType(IFabricAsyncOperationContext context)
at System.Fabric.Interop.Utility.<>c__DisplayClassa.<WrapNativeAsyncInvoke>b__9(IFabricAsyncOperationContext context)
at System.Fabric.Interop.AsyncCallOutAdapter2`1.Finish(IFabricAsyncOperationContext context, Boolean expectedCompletedSynchronously)
--- End of inner exception stack trace ---
Register-ServiceFabricApplicationType : Operation timed out.
At line:1 char:1
+ Register-ServiceFabricApplicationType -ApplicationPathInImageStore 'M ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationTimeout: (Microsoft.Servi...usterConnection:ClusterConnection) [Register-ServiceFabricApplicationType], TimeoutException
+ FullyQualifiedErrorId : RegisterApplicationTypeErrorId,Microsoft.ServiceFabric.Powershell.RegisterApplicationType
Any help greatly appreciated!
If this is a cluster that is hosted by Azure, these settings will be reverted to default values the next time cluster code or configuration upgrade is performed. Please change them by setting the value in the Service Fabric resource via Azure Resource Explorer or PowerShell. This will ensure that these settings are preserved.
"fabricSettings": [
{
"name": "EseStore",
"parameters": [
{
"name": "MaxCursors",
"value": "32768"
}
]
}
],
On the local development cluster you can modify the default cluster manifest XML files located in C:\Program Files\Microsoft SDKs\Service Fabric\ClusterSetup\ with following section and then recreate the cluster.
<Section Name="EseStore">
<Parameter Name="MaxCursors" Value="32768" />
</Section>
Here's what worked for us in a very similar situation:
Please apply the following mitigation steps (one node at a time) on all nodes:
Go to data root of cluster, by default it is “D:\SvcFab\” or C:\ProgramData\Microsoft\SF if you didn’t specify datapath attribute in deployment. Look for folder by name . Inside that folder you will see file Fabric.Package.current.xml. create a backup.
Open the Fabric.Package.current.xml file and look for Fabric.Config version:
Go to config folder for that version and look for Settings.xml file.
Take a backup of Settings.xml file and open the Settings.xml file.
Look for section named “EseStore”.
<Section Name="EseStore">
</Section>
If section is present, add this parameter to section (prefer to type these text in the Settings.xml file than copy-pasting as copy-pasting sometimes appends extra invalid characters at the end).
<Section Name="EseStore">
<Parameter Name="MaxCursors" Value="32768" />
</Section>
If the section with name “EseStore” is not present, add the section name with parameter as and save the file.
Kill FileStoreService.exe on the node.
Wait for the FileStoreService.exe to come back up and then proceed to next node.
After you are done applying mitigation to all nodes and cluster is back up healthy, please retry deploying the package. Please make sure for testing in testing machine first before use on production.

A parameter cannot be found that matches parameter name 'MaxSizeGB'

New-AzureSqlDatabase command on execution suddently started failing with parameter not found message. MSDN link mentions the parameter as supported.
https://msdn.microsoft.com/en-us/library/dn546722.aspx
Command : New-AzureSqlDatabase
Input
PS C:\scripts>$database1 = New-AzureSqlDatabase -ServerName
"lpqd0zbrseg" -DatabaseName "Database1" -Edition "Business" -MaxSizeGB
50 -Collation "SQL_Latin1_General_CP1_CI_AS"
Output Error
New-AzureSqlDatabase : A parameter cannot be found that matches
parameter name 'MaxSizeGB'. At line:1 char:103
+ ... dition "Basic" -MaxSizeGB 1 -Collation "SQL_Latin1_General_CP1_CI_AS"
+ ~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-AzureSqlDatabase], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.Azure.Commands.Sql.Database.Cmdlet.NewAzureSqlDatabas
What would be the reason that MaxSizeGB parameter got not found on execution. Thanks in advance
With Regards,
H Bala
Business and Wed editions are a deprecated service level. Now, the service levels are Free, Basic, Standard & Premium as the error shows.
About the parameter, are you using the Azure PowerShell module configured as "Resource Manager" or "Service Management"? The first one hasn't that value but the second one have it.
You can change it with "Switch-AzureMode". You can find the explanation in the second section of the page.
Source Code of Resource Manager command
Source Code of Service Management command

Powershell and System.Security.Cryptography.X509Certificates.X509Certificate2

i'm getting this error when i run the system.security namespace. This is what i am running after
$cert=New-Object System.Security.Cryptography.X509Certificates.X509Certificate2("C:\mycert.cer")
New-Object: Cannot find type [System.Security.Cryptography.X509Certificates.X509Certificate2("C:\mycert.cer")]: make sure the assembly containing this type is loaded.
At line:1 char:19
+ $cert = New-Object <<<<
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand**
What am i doing wrong?
Try running this to see if you have the System.dll loaded (should be by default):
[AppDomain]::CurrentDomain.GetAssemblies() |
Where {$_.Location -match '\\System\\'}
If it is loaded then this command should show the X509Certificate2 type:
[AppDomain]::CurrentDomain.GetAssemblies() |
Where {$_.Location -match '\\System\\'} |
%{$_.GetExportedTypes()} | Where {$_.Name -match 'X509Cert'}
If the System.dll isn't loaded (which would be odd) try loading it:
Add-Type -AssemblyName System
See: http://technet.microsoft.com/en-us/library/hh849914.aspx
FYI ... I got error:
Unable to find type [System.Security.Cryptography.x509Certificates.X509Certificate2UI]
when using:
$certSelect = [System.Security.Cryptography.x509Certificates.X509Certificate2UI]::SelectFromCollection($certCollection, $title, $msg, 0)
However, I had no error creating the collection earlier on in my script:
$certCollection = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2Collection
To make the error go away I had to include the following at some point earlier on:
Add-Type -AssemblyName System.Security
I've solved my problem. It's easily:
cd\
$cert=New-Object System.Security.Cryptography.X509Certificates.X509Certificate2("C:\mycert.cer")
cd\ is necessary
I ran into this in the ISE (but seems to apply to the normal command window too) and it seems that using autocomplete will automatically Add-Type for whatever you're looking for. If you start a new instance and run:
[AppDomain]::CurrentDomain.GetAssemblies() | grep Security
it will not return System.Security, but if you then type this and let intellisense do its thing:
[System.
You can then run this again:
[AppDomain]::CurrentDomain.GetAssemblies() | grep Security
And it will then return System.Security. So this is why you can write a script that works fine, and then revisit it later and it's broken. Using intellisense doesn't fix your script though, instead you have to add this line:
Add-Type System.Security
Or whatever library is not getting auto-added (it seems to need the dll filename, e.g. C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Security.dll).
I'm pretty sure IseSteroids (a paid ISE add-in) can detect this, maybe others as well.

I want to add web part in web part zone using powershell script

I want to add web part in the web part zone programmatically only using power shell script
I am getting this exception using power shell scripting
Exception code
$webPart = $webpartmanager.ImportWebPart($xmlReader, $errorMsg) -as [Microsoft.SharePoint.WebPartPages.WebPart]
Argument: '2' should be a System.Management.Automation.PSReference. Use [ref].
+ $webPart = $webpartmanager.ImportWebPart <<<< ($xmlReader, $errorMsg) -as [Microsoft.SharePoint.WebPartPages.WebPart]
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : NonRefArgumentToRefParameterMsg
Have you tried what the error message suggests (note the addition of [ref] before $errorMsg)?
$webPart = $webpartmanager.ImportWebPart($xmlReader, [ref]$errorMsg)
-as [Microsoft.SharePoint.WebPartPages.WebPart]

Resources