首页 文章
  • 0 votes
     answers
     views

    在C#脚本中执行PowerShell cmdlet

    我想用C#连接交换并返回特定用户的邮箱列表 . 我能够在PowerShell中本地运行它,但是在脚本的上下文中它没有显示我的期望 . 我看到的输出如tmp_1qf14mc3.wiv或tmp_ra1gbenl.ols而不是邮箱列表 . Additional notes: 我已经设置了对System.Management.Automation的名称空间的引用和导入; 我是通过Visual St...
  • 2 votes
     answers
     views

    有没有办法将Azure Powershell Cmdlet子类化 - 或类似的东西?

    我正在编写一些PowerShell cmdlet来自动配置Azure订阅 . 其中一个用例是让开发人员配置他们自己的环境 . 目前,这需要大约20个步骤并且容易出错 . 将它们交给一些默认的azure cmdlet会比使用Microsoft的Azure GUI和一组指令更容易出错 . 我想要一个脚本来完成配置过程,并抽象出大量的簿记和错误检查 . 我尝试在Powershell脚本中完成所有这些操作...
  • 1 votes
     answers
     views

    Powershell:从cmdlet中获取默认目录

    我正在写一个powershell cmdlet . 从我的cmdlet BeginProcessing()方法内部,我希望能够在调用cmdlet时检索作为默认目录的目录 . 示例:如果用户执行此操作: cd \myDirectory invoke-mycmdlet 我希望我的代码知道默认的shell目录是c:\ myDirectory . 当我访问Environment.CurrentDirec...
  • 1 votes
     answers
     views

    从ps脚本调用powershell cmdlet

    我有一个cmdlet具有以下定义: [CmdletBinding(DefaultParameterSetName="Path", SupportsShouldProcess=$TRUE)] param( [parameter(Mandatory=$TRUE,Position=0)] [String] $Pattern, [param...
  • 0 votes
     answers
     views

    我的cmdlet无法注册

    基本上代码来自msdn.microsoft.com 构建代码后,打开命令提示符并输入:Installutil -i%path%/ Mycmdlets.dll 结果表明安装阶段成功完成,提交阶段也成功完成 . 但是,如果我去: Get-PSSnapin -Registered,只显示sqlServerCmdletSnapin,但我的cmdlet不存在 . 添加pssnapin也不起作用 . usin...
  • 1 votes
     answers
     views

    在C#中运行PowerShell cmdlet

    我需要在Visual Studio控制台中使用C#运行powershell cmdlet . using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Management.Automation; u...

热门问题