add-type

How I can use Add-Type in powershell through command line in order to execute VB.NET or C# (or JScript.net) code?

青春壹個敷衍的年華 提交于 2020-05-16 07:30:52
问题 Here's the MS documentation concerning Add-Type So I'm trying to add type through command line: >powershell Add-Type -TypeDefinition "public class T{public static int Add(int a, int b){return (a + b);}}" -Language CSharp or >powershell Add-Type -TypeDefinition "@"""public class T{public static int Add(int a, int b){return (a + b);}}"""@" -Language CSharp or >powershell Add-Type -TypeDefinition "@"""public class T{public static int Add(int a, int b){return (a + b);}}"""@" -Language CSharp or

How I can use Add-Type in powershell through command line in order to execute VB.NET or C# (or JScript.net) code?

蓝咒 提交于 2020-05-16 07:28:28
问题 Here's the MS documentation concerning Add-Type So I'm trying to add type through command line: >powershell Add-Type -TypeDefinition "public class T{public static int Add(int a, int b){return (a + b);}}" -Language CSharp or >powershell Add-Type -TypeDefinition "@"""public class T{public static int Add(int a, int b){return (a + b);}}"""@" -Language CSharp or >powershell Add-Type -TypeDefinition "@"""public class T{public static int Add(int a, int b){return (a + b);}}"""@" -Language CSharp or

How to add mime types to an htaccess file?

老子叫甜甜 提交于 2019-12-20 01:08:12
问题 I'm having an issue adding a mime type to my server. This is my current .htaccess: AuthUserFile /usr/local/www/pass/.htpasswd AuthType Basic AuthName "Mockups" <LIMIT GET POST> require valid-user </LIMIT> I want to add this: AddType audio/mpeg .mp3 But when I do, I get a 500 Internal Server Error. I then reup the .htaccess file without the "AddType" line and it works fine again. What could be the issue? 回答1: You need AllowOverride FileInfo in your virtualhost configuration and for the

How do I conditionally add a class with Add-Type -TypeDefinition if it isn't added already?

旧时模样 提交于 2019-12-18 13:53:53
问题 Consider the following PowerShell snippet: $csharpString = @" using System; public sealed class MyClass { public MyClass() { } public override string ToString() { return "This is my class. There are many others " + "like it, but this one is mine."; } } "@ Add-Type -TypeDefinition $csharpString; $myObject = New-Object MyClass Write-Host $myObject.ToString(); If I run it more than once in the same AppDomain (e.g. run the script twice in powershell.exe or powershell_ise.exe) I get the following

Powershell load dll got error: Add-Type : Could not load file or assembly 'WebDriver.dll' or one of its dependencies. Operation is not supported

你离开我真会死。 提交于 2019-12-18 11:53:16
问题 I want to use PowerShell with selenium and download selenium from http://www.java2s.com/Code/Jar/s/Downloadseleniumremotedriver2350jar.htm . When I try to load one of the dlls, I got errors. Hope someone can help me with it. This is my system info. OS Name: Microsoft Windows 7 Enterprise OS Version: 6.1.7601 Service Pack 1 Build 7601 OS Manufacturer: Microsoft Corporation This is my PowerShell info. PS C:\Users\test\Downloads\selenium-dotnet-2.35.0\net40> $psversiontable Name Value ---- -----

Can you remove an Add-ed Type in PowerShell again?

孤人 提交于 2019-12-17 17:53:15
问题 I'm currently writing a library in C# and was using PowerShell to quickly test it on some occasions. However, this prevents me from re-building the project as PowerShell obviously still has the DLL open. Is there a way of unloading the DLL again after adding it with Add-Type ? The documentation doesn't seem to have clues on that and the obvious candidate would be Remove-Type (which doesn't exist – there is only one command anyway with Type as its noun). It gets cumbersome to close PowerShell

Add-Type load assembly from network UNC share error 0x80131515

若如初见. 提交于 2019-12-17 16:49:11
问题 When you want to add an assembly from a network UNC share using the command: $scriptPath = Split-Path ($MyInvocation.MyCommand.Path) Add-Type -path "$scriptPath\selenium-dotnet\net40\WebDriver.dll" you might face such an error: Add-Type: Could not load file or assembly 'file:///Z:\A-Backup\Users\Administr ator\Desktop\MAXIMO Automatic\selenium-dotnet\net40\WebDriver.dll' or one of it s dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515 ) At Z:\A-Backup\Users

Powershell: Unable to find type when using PS 5 classes

本秂侑毒 提交于 2019-12-04 20:15:04
问题 I'm using classes in PS with WinSCP Powershell Assembly. In one of the methods I'm using various types from WinSCP. This works fine as long as I already have the assembly added - however, because of the way Powershell reads the script when using classes (I assume?), an error is throwed before the assembly could be loaded. In fact, even if I put a Write-Host at the top, it will not load. Is there any way of forcing something to run before the rest of the file is parsed? Transfer() { $this

Powershell: Unable to find type when using PS 5 classes

孤人 提交于 2019-12-03 12:43:35
I'm using classes in PS with WinSCP Powershell Assembly. In one of the methods I'm using various types from WinSCP. This works fine as long as I already have the assembly added - however, because of the way Powershell reads the script when using classes (I assume?), an error is throwed before the assembly could be loaded. In fact, even if I put a Write-Host at the top, it will not load. Is there any way of forcing something to run before the rest of the file is parsed? Transfer() { $this.Logger = [Logger]::new() try { Add-Type -Path $this.Paths.WinSCP $ConnectionType = $this.FtpSettings

How to add mime types to an htaccess file?

懵懂的女人 提交于 2019-12-01 18:56:19
I'm having an issue adding a mime type to my server. This is my current .htaccess: AuthUserFile /usr/local/www/pass/.htpasswd AuthType Basic AuthName "Mockups" <LIMIT GET POST> require valid-user </LIMIT> I want to add this: AddType audio/mpeg .mp3 But when I do, I get a 500 Internal Server Error. I then reup the .htaccess file without the "AddType" line and it works fine again. What could be the issue? You need AllowOverride FileInfo in your virtualhost configuration and for the directory in which the .htaccess file is located, to be able to use AddType directive. 来源: https://stackoverflow