小编Kna*_*aks的帖子

Powershell和C#中此运行空间不支持语法

我正在尝试使用C#中集成的Power Shell获取有关用户邮箱的信息,但出现以下错误:

This syntax is not supported by this run space. This might be because it is no-language mode.
Run Code Online (Sandbox Code Playgroud)

这是我正在使用的代码:

using System;
using System.Collections.ObjectModel;
using System.Collections;
using System.Linq;
using System.Text;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
using System.Threading;
using System.Globalization;

namespace Office365
{
    class Program
    {
        static void Main(string[] args)
        {
            CultureInfo oldCI = Thread.CurrentThread.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

            System.Security.SecureString secureString = new System.Security.SecureString();
            string myPassword = "mySecretPassword";
            foreach (char c in myPassword)
                secureString.AppendChar(c);
            PSCredential credential = new PSCredential("my@maildomain.com", …
Run Code Online (Sandbox Code Playgroud)

c# powershell office365

5
推荐指数
1
解决办法
2494
查看次数

标签 统计

c# ×1

office365 ×1

powershell ×1