如何从字符串中提取"程序名称".字符串将如下所示:
%O0033(SUB RAD MSD 50R III)G91G1X-6.4Z-2.F500 G3I6.4Z-8.G3I6.4 G3R3.2X6.4F500 G91G0Z5.G91G1X-10.4 G3I10.4 G3R5.2X10.4 G90G0Z2.M99%
程序名称为(SUB RAD MSD 50R III).将结果存储在另一个字符串中很好.我正在学习powershell,所以任何解释你的答案将不胜感激.
我是SSIS的新手,我正在尝试将GetDate()转换为字符串"DD-MM-YYYY".这是我到目前为止构建的表达式:
(DT_WSTR, 8) DAY( GETDATE()) + "-" + (DT_WSTR, 8) (MONTH(GETDATE()) - 1) + "-" + (DT_WSTR, 8) YEAR(GETDATE())
Run Code Online (Sandbox Code Playgroud)
我得到的问题是Month()将月份"23-4-2013"转换为单个字符,当我想要它的双字符时,与日相同.无论几个月,我如何将它变成双重角色?
我想测试是否已为变量分配了变量,如果没有执行操作.怎么能实现呢?
我尝试使用以下代码但收到错误:'-is'的右操作数必须是一个类型.
此时未分配$ ProgramName.
If ($ProgramName -isnot $null) {
$ProgramName = $ProgramName + ', ' + $cncPrograms
}
Else {
If ($cncPrograms -isnot $null) {
$ProgramName = $cncPrograms
}
}
Run Code Online (Sandbox Code Playgroud) 什么是在PowerShell脚本中测试管理权限的最佳/最简单方法?
我需要编写一个需要管理权限的脚本,并希望了解实现它的最佳方法.
为什么下面的脚本会出现以下错误?
"Add-Member:由于一个或多个缺少
必需参数而无法处理命令:InputObject.
+ $ obj = Add-Member <<<< -MemberType NoteProperty -Name ComputerName -Value $ ComputerName
+ CategoryInfo:InvalidArgument:(:) [Add -Member],ParameterBindingException
+ FullyQualifiedErrorId:MissingMandatoryParameter,Microsoft.PowerShell.Commands.AddMemberCommand"
# Receives the computer name and stores the required results in $obj.
Function WorkerNetworkAdaptMacAddress {
Param($ComputerName)
$colItems = GWMI -cl "Win32_NetworkAdapterConfiguration" -name "root\CimV2" -comp $ComputerName -filter "IpEnabled = TRUE"
$obj = New-Object -TypeName PSobject
ForEach ($objItem in $colItems)
{
$obj = Add-Member -MemberType NoteProperty -Name ComputerName -Value $ComputerName
$obj = Add-Member -MemberType NoteProperty -Name MacAddress -Value $objItem.MacAddress …
Run Code Online (Sandbox Code Playgroud) 当我运行下面的脚本来检索日志文件时,get-winevent"message"字段为空,但是如果我运行get-eventlog则有数据.有什么想法吗?
#has message data
Get-Eventlog -LogName application -Newest 10
#date 10 days ago
$EventStartDate = get-date("10 May 2012")
$EventEndDate = get-date("11 May 2012")
$EventLogNames = @("Application", "system")
#critea for winevent
$EventCritea = @{logname = $EventLogNames; StartTime=$EventStartDate; EndTime=$EventEndDate}
#Retrieves the event log
$RetreivedEvents = Get-WinEvent -computername localhost -FilterHashtable $EventCritea
$RetreivedEvents | fl id, logname, MachineName, Message, TimeCreated
Run Code Online (Sandbox Code Playgroud) 当我从 Visual Studio 代码(Windows 计算机)到 Raspberry PI 运行以下调试时。我两次收到以下错误:
pydev 调试器:警告:尝试向不存在的文件添加断点:/home/pi/testdebug/C:/IOT/Github/RaspberryPi/test_remote_debug/test_remote_debug.py(将无效)
pydev 调试器:警告:尝试向不存在的文件添加断点:/home/pi/testdebug/C:/IOT/Github/RaspberryPi/ReadPressure/Testing_bar_broke_notification.py(将无效)
这是 lauch.json 中的设置:
{
"name": "Python Attach (Remote Debug blah blah )",
"type": "python",
"request": "attach",
"pathMappings": [
{
"localRoot": "${workspaceFolder}", // You may also manually specify the directory containing your source code.
"remoteRoot": "/home/pi/testdebug/" // Linux example; adjust as necessary for your OS and situation.
}
],
"port": 3000, // Set to the remote port.
"host": "192.34.98.197" // Set to your remote host's public IP address.
} …
Run Code Online (Sandbox Code Playgroud) 我刚刚在 Visual Studio 代码上设置了 jupyter Nodebooks,每当我运行它时,它都会显示“此功能需要 ipykernel 设置”。关于如何让它发挥作用有什么想法吗?
这个网站说要检查版本,我能看到的唯一差异是 Jupiter 插件,其中说我应该在 Jupyter Extension v2021.9,但我在 Jupyter Extension v2021.8。我看不到版本 9...我安装的版本是最新版本。
*** 更新,我安装了最新版本的 vscode,这允许我安装更高版本的 jupyter。但是我仍然遇到同样的问题。我现在运行 jpyter 版本 v2021.10.1101450599
import ipykernel
ipykernel.__version__
Run Code Online (Sandbox Code Playgroud)
‘6.5.1’
import sys
sys.version
Run Code Online (Sandbox Code Playgroud)
3.8.8(默认,2021 年 4 月 13 日,15:08:03)[MSC v.1916 64 位 (AMD64)]
我使用视觉stduio代码版本:1.60.2(系统设置)提交:7f6ab5485bbc008386c4386d08766667e155244e日期:2021-09-22T12:00:31.514Z电子:13.1.8 Chrome:91.0.4472.164 Node.js:14.1 6.0 V8:9.1。 269.39-电子.0 操作系统:Windows_NT x64 10.0.19041
Jupyter笔记本版本v2021.8.2041215044
我已经看过C#和其他一些语言的文章解释了如何实现我正在寻找但我不知道如何转换它们.
以下链接说明了如何获得答案: 如何获取USB设备的驱动器号?
Win32_DiskDrive-> Win32_DiskDriveToDiskPartition - > Win32_DiskPartition - > Win32_LogicalDiskToPartition - > Win32_LogicalDisk
第三个答案(由GEOCHET解释)也解释了如何实现答案,但不是在powershell中.
get-winevent开始和结束日期不是过滤记录.谁能告诉我为什么?我希望从最近2天的事件下面的代码,但我得到的日期可以追溯到2010年(我的Windows时钟日期是正确的)
[String]$ComputerName = $env:COMPUTERNAME#Current computer
[String[]]$EventLogNames=@("Application","System")#Main eventlogs
[System.DateTime[]]$EventStartDate = (((Get-Date).addDays(-2)).date)#date 10 days ago
[System.DateTime[]]$EventEndTime = (Get-Date)
$EventCritea = @{logname = $EventLogNames; StartTime=$EventStartDate; EndTime=$EventEndTime}
Get-WinEvent -ComputerName $ComputerName -FilterHashTable $EventCritea -ErrorAction SilentlyContinue
Run Code Online (Sandbox Code Playgroud) powershell ×7
debugging ×2
wmi ×2
admin-rights ×1
date ×1
event-log ×1
event-viewer ×1
events ×1
expression ×1
getdate ×1
if-statement ×1
object ×1
pipeline ×1
python ×1
regex ×1
ssis ×1
string ×1
sysadmin ×1
text ×1
usb ×1
variables ×1