小编lar*_*400的帖子

设置绑定顺序时如何使注册表值逐行插入?

我正在尝试设置网卡的绑定顺序。我编写了以下代码,按照我需要的顺序遍历我想要的网卡。注册表项需要接受所有网卡,否则它将无法工作,并且该注册表项必须设置为MULTI_SZ

我遇到的问题是,当我组合所有 GUID 时,$Combine它不会逐行拆分每个 GUID,而是将其显示在一大长行中。我将“n”放在每个 GUID 的开头,以便它们进入每行,但它仍然不起作用。

的输出$combine看起来很好,并按照我想要的顺序显示它,但是,当它们被放入注册表项时,它是一大行(参见下面的屏幕截图)

\Device\{2533855F-2A59-485D-87A0-167E5DA39E45}
\Device\{B7883140-E15B-4409-BA1B-96E37A45425C}
\Device\{1FE01120-3866-437F-81FF-556B08999AA4}
\Device\{4A208C06-0D99-4DE4-9B2F-86285AEF864E} 
\Device\{D129DDA8-C64B-46A1-B99A-EA74FC4FAF81} 
\Device\{2A6471FB-C1D6-47D2-A665-9F276D142D7C} 
\Device\{D5C9183B-E542-4010-866F-4443AD55F28C} 
\Device\{306D2DED-18B5-45D8-858E-BB3F49E3BD6A} 
\Device\{30EF50B2-E4B3-400D-9614-B590E37DE4D8}
Run Code Online (Sandbox Code Playgroud)

那么问题来了,如何才能让结果逐行显示呢?

代码:

$TeamConnection = Get-WmiObject -Class win32_networkadapter | where {$_.Netconnectionid -ne $null -and $_.NetconnectionID -eq "Team"} | select -ExpandProperty GUID
$Prod1Connection = Get-WmiObject -Class win32_networkadapter | where {$_.Netconnectionid -ne $null -and $_.NetconnectionID -eq "Prod1"} | select -ExpandProperty GUID
$Prod2Connection = Get-WmiObject -Class win32_networkadapter | where {$_.Netconnectionid -ne $null -and $_.NetconnectionID -eq "Prod2"} | select -ExpandProperty GUID
$EverythingElse …
Run Code Online (Sandbox Code Playgroud)

powershell

4
推荐指数
1
解决办法
342
查看次数

使用函数中的值并将其传递给另一个函数

我有以下两个函数,我想要在Comparision函数中使用的ROBOCOPY函数的SOURCE和TARGET.任何人都可以告诉我该怎么做.谢谢.

Write-Host "==================================" -ForegroundColor Magenta -BackgroundColor White
Write-Host "Pre-Staging Script for DFSR Server" -ForegroundColor Magenta -BackgroundColor White
Write-Host "==================================" -ForegroundColor Magenta -BackgroundColor White
Write-Host ""
Function GetHot-Fix
{
                Write-Host "==================================" -ForegroundColor Magenta -BackgroundColor White
                Write-Host "Checking Service Installation" -ForegroundColor Magenta -BackgroundColor White
                Write-Host "==================================" -ForegroundColor Magenta -BackgroundColor White
                Write-Host ""
                write-host "This will check if Hotfix KB979808 is installed." -ForegroundColor Black -BackgroundColor Cyan
                write-host "This is required for Windows Server 2008 R2 Robocopying"  -ForegroundColor Black -BackgroundColor Cyan
                Write-Host ""

                Get-HotFix …
Run Code Online (Sandbox Code Playgroud)

powershell

3
推荐指数
1
解决办法
2万
查看次数

单个服务器上的get-hotfix

第一次使用powershell,我似乎无法让下面的工作 - 没有任何显示 - 我认为脚本工作但我认为我需要一些东西来显示结果?任何帮助请:

$hotfix1 = Get-HotFix -Id KB981872

If($hotfix)
{
$Output = "Hotfix is installed you may proceed"
}
else
{
$Output = "Hotfix is not installed"
}
$hotfix1 = Get-HotFix -Id KB981872
Run Code Online (Sandbox Code Playgroud)

谢谢谢伊 - 我已将其更新为:

 write-host "This will check if Hotfix KB979808 is installed on this Server." -ForegroundColor 

Black -BackgroundColor Cyan
write-host "This is required for Windows Server 2008 R2 DFSR Pre-Seeding Robocopying"  -

ForegroundColor Black -BackgroundColor Cyan
Write-Host ""

$hotfix1 = Get-HotFix -Id KB979808 -ErrorAction SilentlyContinue …
Run Code Online (Sandbox Code Playgroud)

powershell

2
推荐指数
1
解决办法
1304
查看次数

文本框接受输入/返回

我有下面的代码,允许用户写入可执行文件(即notepad.exe),然后单击开始按钮,它将启动该过程.

但是,如何让文本框接受输入/返回键?我投入AcceptsReturn=true但它没有做任何事情.我还在Visual Studio中设置了属性Accept Return = True- 仍然没有.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;

namespace process_list
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

       private void button1_Click(object sender, EventArgs e)
        {

            string text = textBox1.Text;
            Process process = new Process();
            process.StartInfo.FileName = text;
            process.Start();

        }

       private void textBox1_TextChanged(object sender, EventArgs e)
       {
           textBox1.AcceptsReturn = true;
       }
    }
}
Run Code Online (Sandbox Code Playgroud)

c# winforms

2
推荐指数
2
解决办法
1万
查看次数

如何在一行中输入用户的日期和时间

如何将以下所有内容放入一行以便用户能够立即输入?

因此,不是Read-Host每次他们想要输入内容时都会弹出 - 它会弹出一次并说明您想要输入的日期。

所以 - “请输入完整的日期和时间 - 即 2012 年 10 月 25 日 9:00”

另外 - 如果有人输入了奇怪的字符,我该如何让它出错?

$Day = $(Read-Host "Enter day of month")
if ($Day -eq ''){$Day = Get-Date -format dd}

$Month = $(Read-Host "Enter Month of Year")
if ($Month -eq ""){$Month = Get-Date -format MM}

$Year = $(Read-Host "Enter Year")
if ($Year -eq "") {$Year = Get-Date -format yy}

$Hour = $(Read-Host "Enter Hour")
if ($Hour -eq "") {$Hour = Get-Date -Format HH}

$Minute …
Run Code Online (Sandbox Code Playgroud)

powershell powershell-2.0

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

TCP烟囱命令通过Powershell

我有以下情况,我一直试图上班,但现在不能.我希望它通过并获得netsh命令的输出,但我需要的是检查三个输出.

如果我只运行它,这是命令输出:

netsh int tcp show global | where {$_ -match ': disabled'}


Receive-Side Scaling State          : disabled 
Chimney Offload State               : disabled 
Direct Cache Acess (DCA)            : disabled 
Receive Window Auto-Tuning Level    : disabled 
ECN Capability                      : disabled 
RFC 1323 Timestamps                 : disabled
Run Code Online (Sandbox Code Playgroud)

然后,如果我运行以下来获得例如"Chimney Offload State"并检查它是否设置为DISABLED然后它失败并且进入ELSE声明说它被设置为ENABLED当它不是...任何想法如何解决请这个:

码:

clear
$netsh = netsh int tcp show global | where {$_ -match ': disabled'}

if ($netsh -eq 'Chimney Offload State               : disabled')
{
    Write-Host "TCP Chimney disabled"
}
else
{
    Write-Host "TCP …
Run Code Online (Sandbox Code Playgroud)

powershell powershell-2.0 powershell-3.0

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

在C#中,SQL连接正在打印:'System.Data.SqlClient.SqlDataReader'

我想在C#中运行一个SQL语句

这是代码:

static void Main(string[] args)
{
    SqlConnection conn = new SqlConnection(
        @"Data Source=loninasd023.xx.xx.com;Initial 
        Catalog=DB.Manager.Data;Integrated Security=SSPI;");

    if (impersonateValidUser("svc_mgr", "USERNAME", "PASSWORD"))
    {
        conn.Open();
        SqlCommand cmd = new SqlCommand(
          "SELECT [data_check_info] FROM [DB.Manager.Data].[dbo].[server_package_status]", 
          conn);

        SqlDataReader reader = cmd.ExecuteReader();

        while (reader.Read())
        {
            Console.WriteLine(reader);
        }

        reader.Close();
        conn.Close();

    }
    else
    {
        Console.WriteLine("The impersonation failed.");
        Environment.Exit(100);
    }

}
Run Code Online (Sandbox Code Playgroud)

该程序打印这个:

System.Data.SqlClient.SqlDataReader
System.Data.SqlClient.SqlDataReader
System.Data.SqlClient.SqlDataReader
System.Data.SqlClient.SqlDataReader
System.Data.SqlClient.SqlDataReader
System.Data.SqlClient.SqlDataReader
System.Data.SqlClient.SqlDataReader
System.Data.SqlClient.SqlDataReader
System.Data.SqlClient.SqlDataReader
System.Data.SqlClient.SqlDataReader
System.Data.SqlClient.SqlDataReader
System.Data.SqlClient.SqlDataReader
System.Data.SqlClient.SqlDataReader
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

c# sqldatareader

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

删除 ApplicationHost 配置文件中的元素

我正在尝试centralBinaryLogFile从 applicationHost 配置文件中删除元素:

我正在使用以下内容来删除它:

 Remove-WebConfigurationProperty -PSPath 'MACHINE/WEBROOT/APPHOST' -Filter 'system.applicationHost/log' -Name 'centralBinaryLogFile'
Run Code Online (Sandbox Code Playgroud)

但是,每当我尝试使用以下命令将其删除时它都会抱怨:

**WARNING: Property centralBinaryLogFile is not found on  /system.applicationHost/log.**
Run Code Online (Sandbox Code Playgroud)

我知道它存在,就好像我运行下面我得到的元素很好:

Get-WebConfigurationProperty -PSPath 'MACHINE/WEBROOT/APPHOST' -Filter 'system.applicationHost/log' -Name 'centralBinaryLogFile'


enabled           : True
directory         : %SystemDrive%\inetpub\logs\LogFiles
period            : Daily
truncateSize      : 20971520
localTimeRollover : False
ItemXPath         : /system.applicationHost/log
Attributes        : {enabled, directory, period, truncateSize...}
ChildElements     : {}
ElementTagName    : centralBinaryLogFile
Methods           : 
Schema            : Microsoft.IIs.PowerShell.Framework.ConfigurationElementSchema
Run Code Online (Sandbox Code Playgroud)

我还尝试使用下面的想法,认为哈希表可能会奏效 - 但随后它抱怨 Name 不是一个集合

Remove-WebconfigurationProperty -Filter "system.applicationHost/log" "Machine/WebRoot/AppHost" -Name centralBinaryLogFile -AtElement @{ElementTagName="centralBinaryLogFile"}
Run Code Online (Sandbox Code Playgroud)

任何想法我如何删除它?

iis powershell

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