gpt4 book ai didi

powershell - 在哪里可以找到一些Powershell语法

转载 作者:行者123 更新时间:2023-12-03 00:31:57 25 4
gpt4 key购买 nike

我只是在阅读一些powershell脚本,发现其中有些脚本是这样的:$ExecutionContext.InvokeCommand.GetCommand[System.Management.Automation.CommandTypes]::Cmdlet)[System.Reflection.Assembly]::ReflectionOnlyLoadFrom($_.FullName)我的意思是在哪里可以找到它们的含义?在Microsoft上是否有任何页面列出了它们中的每一个及其正确含义?谢谢

最佳答案

您搜寻了什么?

所有文档均可在线获得,做您所看到的事情是很平常的事情。因此,只要您看到此用例...

[System.

...这是为了满足目标而调用Windows .Net库。所有这些都在MSDN和.Net文档站点上进行了介绍。

'powershell using .net classes'

返回示例

PowerShell: How to Create and Use Classes

PowerShell has the capability to create .Net Framework classes using the Add-Type Jump cmdlet. To create classes, the C# language can be used to define the classes. C# is part of Visual Studio, but having Visual Studio is not necessary to create classes for use in PowerShell. The C# class definitions can be part of the PowerShell script file. No DLL files to worry about installing.


$PeopleDefinition=@"
using System;
using System.Collections;
using System.Collections.Generic;

namespace People
{
public enum Gender

{
Unknown,
Male,
Female
}

public class Person {}
public class Persons {}
public class People {}
public static class Factory {}
}
"@

Add-Type -TypeDefinition $PeopleDefinition
Remove-Variable PeopleDefinition
$People = [People.Factory]::BuildPeople()
$Person = $People["Person"]

'powershell using .net namespace'

返回示例:

Discover the Dot NET Namespace and WMI Class-Powershell

.NET Namespace-Powershell

All Scripts in this Blog written using .NET Namespace so we don't have the Module Dependency.

Now a days there are so many Modules are available in Powershell. For our daily operation those are very helpful.If we using built-in Module there are few challenges like If we are used "ActiveDirectory" Module; that module is available in Domain Controler or you need to install that manually. In this case if we want manage our AD; we need "ActiveDirectory" Module. That is the reason I am putting this topic in this blog. If you are used .NET namespace you don't need the Module.

If we are used .NET name space instead of Powershell Module which is available in all Windows 2008 System. Also we don't have any Module available in Windows 2008 for manageing the Microsoft PKI.

Given few important Namespaces those can make our life easier & we can write our own code without the Powershell Module.

  1. We can manage our Active Directory

NameSpace
[System.DirectoryServices.ActiveDirectory]

您也可以通过使用确切的字符串来搜索您专门要求的项目的Docs / info / examples / explanation。

$ExecutionContext.InvokeCommand.GetCommand

PowerShell Tip: To write a Proxy Function
[System.Management.Automation.CommandTypes]::Cmdlet]

Defines the types of commands that MSH can execute


[System.Reflection.Assembly]::ReflectionOnlyLoadFrom]

Loads an assembly into the reflection-only context, given its path.



更新

我也打算从Microsoft添加这些。

.NET API browser Welcome to the .NET API browser – your one-stop shop for all .NET-based APIs from Microsoft. Start searching for any managed APIs by typing in the box below. You can learn more about the API browser in our blog post. If you have any feedback, create a new issue in the MicrosoftDocs/feedback repository on GitHub.



Platform Invoke (P/Invoke)

How to: Call Native DLLs from Managed Code Using PInvoke

以及用于查找内容的工具,就像上面的.Net允许的那样。

What is PInvoke.net?

PInvoke.net is primarily a wiki, allowing developers to find, edit and add PInvoke* signatures, user-defined types, and any other information related to calling Win32 and other unmanaged APIs from managed code (written in languages such as C# or VB.NET).



这是一个较旧的PowerShell工具,用于浏览类, namespace ,但是它很慢,因为选择列表时需要很长时间才能填充。

PowerShell Object Browser

This is a PowerShell application that displays objects in an explorer type application written in PowerShell. The PowerShell Object Browser displays the properties and child objects / collections for any PowerShell / .Net framework object.For an explantation on how to use this a

Download: PSObjectBrowser.ps1

关于powershell - 在哪里可以找到一些Powershell语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60479330/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com