小编Col*_*337的帖子

什么是在脚本创作和编辑上分享信用的正确方法?

在我的脚本编写漏洞中,我经常检查脚本是否在我从头开始之前编写过.通常我至少可以通过谷歌或其他方式找到我需要的东西.然后我根据自己的需要调整我的需求并将其投入生产.作为一种最佳实践,我评论我的代码并包含作者信息(我不是抄袭的粉丝).然而,问题是如何以及何时适合添加/更改作者名称.我将从他的博客中使用Ed Wilson的示例脚本作为参考:

Function Get-OutlookCalendar {
    <#
   .Synopsis
    This function returns appointment items from default Outlook profile
   .Description
    This function returns appointment items from default Outlook profile. It
    uses the Outlook interop assembly to use the olFolderCalendar enumeration.
    It creates a custom object consisting of Subject, Start, Duration, Location
    for each appointment item.
   .Example
    Get-OutlookCalendar |
    where-object { $_.start -gt [datetime]"5/10/2011" -AND $_.start -lt `
    [datetime]"5/17/2011" } | sort-object Duration
    Displays subject, start, duration and location for all appointments that
    occur …
Run Code Online (Sandbox Code Playgroud)

powershell scripting

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

Powershell ISE在发布时崩溃

不知道为什么,但今天我的工作站拒绝加载Powershell ISE.我可以加载Powershell,我的cmdlet工作正常.我已经尝试加载32位和64位ISE,并且出于同样的原因都崩溃了.

这是crashdump:

问题签名:问题事件名称:PowerShell NameOfExe:PowerShell_ISE.exe FileVersionOfSystemManagementAutomation:6.1.7600.16385 InnermostExceptionType:System.Xml.XmlException
OutermostExceptionType:System.Reflection.TargetInvocation DeepestPowerShellFrame:indows.PowerShell.GuiExe.Internal.GPowerShell.Main DeepestFrame:indows.PowerShell .GuiExe.Internal.GPowerShell.Main ThreadName:未知操作系统版本:6.1.7600.2.0.0.256.48区域设置ID:1033

在线阅读我们的隐私声明:http:
//go.microsoft.com/fwlink/?linkid = 104288&clcid = 0x400

如果没有在线隐私声明,请离线阅读我们的隐私声明:C:\ Windows\system32\en-US\erofflps.txt

在这次崩溃中我在谷歌上找不到任何东西所以我希望有人在这里有一些指导.

crash powershell powershell-ise windows-7

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

Powershell在PSSession中使用Start-Process打开记事本

我在远程计算机上创建了一个pssession并输入了这个属性.在该会话中,我使用start-process启动记事本.我可以确认记事本是使用get-process命令运行的,还是使用远程计算机中的taskmgr运行.但是,该过程的GUI端未显示.这是我一直在使用的序列:

$server = New-PSSession -ComputerName myserver -Credential mycreds
Enter-PSSession $server

[$server]: PS C:\>Start-Process notepad -Wait -WindowStyle Maximized
Run Code Online (Sandbox Code Playgroud)

该过程正在运行,但是当RDP到框时,记事本无法打开.如果我从服务器打开记事本,则会开始一个新的记事本过程.我也试过使用这样的动词参数:

[$server]: PS C:\>Start-Process notepad -Wait -WindowStyle Maximized -Verb Open
Run Code Online (Sandbox Code Playgroud)

同样的结果......过程开始,但没有记事本显示.我已经尝试了这个远程进入盒子(但是从我的本地主机发出)以及远程进入服务器之前.

powershell start-process powershell-3.0

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

Powershell工作流DynamicActivity编译器错误'.' 预期使用$ Date变量

通常,PowerShell错误会给我一些东西,但是这个错误让我经历了一个循环.要测试,请执行以下代码:

workflow test-date{
    $Date = Get-Date -format yyyyMMddHHmm -Verbose

    Write-Output $Date
}
Run Code Online (Sandbox Code Playgroud)

我得到的错误是:

The workflow 'test-date' could not be started: The following errors were encountered while processing the workflow tree:
'DynamicActivity': The private implementation of activity '1: DynamicActivity' has the following validation error:   Compiler error(s) encountered processing expression "Date".
'.' expected.
At line:383 char:21
+                     throw (New-Object System.Management.Automation.ErrorRecord $ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (System.Manageme...etersDictionary:PSBoundParametersDictionary) [], RuntimeException
    + FullyQualifiedErrorId : StartWorkflow.InvalidArgument
Run Code Online (Sandbox Code Playgroud)

真正让我感到高兴的是,它说它期待着"." 某处.我不知道它在哪里找到'.'.我用谷歌搜索了没有产生任何与我的情况相关的错误.我想更多地了解这个错误的含义,以及为什么我会得到它.如果有人知道解决方案,那就太好了.

powershell compiler-errors workflow-foundation

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