PSCustomObject我正在尝试从 robocopy 日志文件创建一个。第一部分很简单,但我在这$Footer部分上遇到了困难。我似乎找不到一个好的方法来分割这些值。
如果每个条目都有自己的Property,那就太好了,这样就可以使用例如$Total.Dirs或$Skipped.Dirs。我正在考虑Import-CSV,因为它非常适合让您拥有列标题。但这似乎不适合这里。我在这里找到了另一种解决方案,但似乎有点矫枉过正。
代码:
Function ConvertFrom-RobocopyLog {
    Param (
        [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true,Position=0)]
        [String]$LogFile
    )
    Process {
        $Header = Get-Content $LogFile | select -First 10
        $Footer = Get-Content $LogFile | select -Last 7
        $Header | ForEach-Object {
            if ($_ -like "*Source*") {$Source = (($_.Split(':'))[1]).trim()}
            if ($_ -like "*Dest*")   {$Destination = (($_.Split(':'))[1]).trim()}
        }
        $Footer | ForEach-Object {
            if ($_ -like "*Dirs*") {$Dirs = (($_.Split(':'))[1]).trim()}
            if ($_ -like "*Files*") {$Files = …Run Code Online (Sandbox Code Playgroud) 考虑以下代码:
export default defineComponent({
  setup() {
    const miniState = ref(true)
    const setMiniState = (state: boolean, screenWidth: number) => {
      if (screenWidth > 1023) {
        miniState.value = false
      } else if (state !== void 0) {
        miniState.value = state === true
      }
      else {
        miniState.value = true
      }
    }
    watch('$q.screen.width', (width) => setMiniState(true, width))
    return { miniState, setMiniState }
  }
})
Run Code Online (Sandbox Code Playgroud)
TypeScript 抛出此错误:
TS2769:没有与此调用匹配的重载。
重载 1 of 3, '(来源: SimpleEffect, options?: Pick, "deep" | "flush"> | undefined): StopHandle',出现以下错误。类型“$q.screen.width”的参数不可分配给类型“SimpleEffect”的参数。重载第 2 个(共 …
javascript typescript vue.js vue-component vue-composition-api
我正在寻找一种方法来检索在活动目录中没有分配给它们的所有用户.无论我尝试什么,它总是吐出错误.
工作良好:
Get-ADUser -Filter {-not(lastLogonTimeStamp -like "*")} -Properties * -SearchBase "xxx"     
Run Code Online (Sandbox Code Playgroud)
不起作用:
Get-ADUser -Filter {-not(manager -like "*")} -Properties * -SearchBase "xxx"
Get-ADUser -Filter {manager -ne "*"} -Properties * -SearchBase "xxx 
Get-ADUser -Filter {manager -eq $null} -Properties * -SearchBase "xxx
Get-ADUser -Filter {manager -notlike '*'} -Properties * -SearchBase "xxx
Run Code Online (Sandbox Code Playgroud)
如果不使用该where子句,是否有人对正确的语法有所了解?
解决方法:
Get-ADUser -SearchBase "xxx" -Filter * -Properties * | where {$_.manager -eq $null}
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助.
我创建了一个高级功能,可以根据Mjolinor提出的答案发送电子邮件。但是,我在让它接受 HTML 代码块时遇到了困难。它抱怨System.String无法转换为System.Management.Automation.SwitchParameter.
对于我的 HTML 代码,我使用了一个 here 字符串,当使用 like 时它可以正常工作,Send-MailMessage -BodyAsHtml $HTML但当我尝试如下时则不行。而且我似乎无法弄清楚如何转换它以便它起作用。
错误:
An error occurred while enumerating through a collection: Collection was modified; enumeration operation may not execute..
At S:\Test.ps1:168 char:9
+         $EmailParams.keys | Where {$EmailParams.$_ -eq $null} | foreach {$EmailP ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Collecti...tableEnumerator:HashtableEnumerator) [], RuntimeException
    + FullyQualifiedErrorId : BadEnumeration
Failed to send email to User@domain.net due to: Cannot convert 'System.String' to the type …Run Code Online (Sandbox Code Playgroud) 我正在使用Windows Server 2012(默认情况下带有各种DFS CmdLets)。
我想做的是获取由域中其他DFS服务器(Win Srv 2008 R2)托管的特定UNC共享的ComputerName和local path。
一个例子:
Get-DfsnFolderTarget -Path '\\domain.net\share\folder\'
Run Code Online (Sandbox Code Playgroud)
预期结果:
ComputerName = 'Server1'
Path         = 'E\Home\folder'
Run Code Online (Sandbox Code Playgroud)
我并不是真正的网络工程师,但似乎找不到基于UNC路径检索此信息的方法。每次我尝试上面的CmdLet时,都会出现错误:
Get-DfsnFolderTarget : Cannot get DFS folder properites on "\\domain.net\share\folder\"
At line:1 char:1
+ Get-DfsnFolderTarget -Path '\\domain.net\share\folder\'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (MSFT_DfsNamespaceFolderTarget:ROOT\Microsoft\...aceFolderTarget) [Ge 
   t-DfsnFolderTarget], CimException
    + FullyQualifiedErrorId : Windows System Error 1168,Get-DfsnFolderTarget
Get-DfsnFolderTarget : The requested object could not be found.
At line:1 char:1
+ Get-DfsnFolderTarget -Path '\\domain.net\share\folder\'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo …Run Code Online (Sandbox Code Playgroud) 如何使Split-String案例不敏感?
这很好用:
$String = '\\domain.net\share\folder\home\bob\stuff'
$String | Split-String -Separator 'home' -Count 2
Run Code Online (Sandbox Code Playgroud)
这不是:
$String = '\\domain.net\share\folder\home\bob\stuff'
$String | Split-String -Separator 'HOME' -Count 2
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个在以下情况下返回TRUE或FALSE的正则表达式:
# Returns TRUE
'Apples: 1'
'Apples: are a fruit'
'Apples: z'
'Apples: I don't care what comes here if it's not only spaces or nothing'
# Returns FALSE
'Apples:'
'Apples:  '
'Apples:     '
Run Code Online (Sandbox Code Playgroud)
到目前为止我所尝试的内容很接近,但我似乎无法涵盖第二部分:
'Apples: ' -match '^Apples:[A-Za-z0-9]*'
Run Code Online (Sandbox Code Playgroud)
唯一的事情就是,需要有一些事情发生在它之后Apples:,这不可能是空间或空白.但是首先或之后会出现一些空格,但确实需要在线上有文字或数值.
谢谢您的帮助.
虽然Java 8我们正在学习一门课程,现在我们正在谈论Generics和Lambda expressions.我们被要求制作以下方法Generic而String不仅仅是:
public static String betterString(String s1,String s2,IBetterString bs){
    if(bs.isBetter(s1, s2)){
        return s1;
    }else{
        return s2;
    }
}
Run Code Online (Sandbox Code Playgroud)
到目前为止,我对此做了以下几点:
public static <T> betterEllement(T s1, T s2, BiPredicate<T, T> bi) {
    if (bi.test(s1, s2)) {
        return s1;
    } else {
        return s2;
    }
}
Run Code Online (Sandbox Code Playgroud)
但看来我Return type根据Intellij是不正确的.我真的不明白为什么会这样,因为我定义<T>为此方法的返回类型.对不起,如果这是一个愚蠢的问题,我只是一个初学者,并想了解为什么它不正确.
我们有一个 Excel 文件,其中有一列Percentage. 此列包含数字,因此能够从大到小和反向排序。唯一缺少的是它没有在数字后面显示百分比符号。
我们拥有的是这样的:
如果它可以显示以下内容并且仍然能够从小到大排序,那就太好了:
114,87 %
50 %
81 %
91 %
Run Code Online (Sandbox Code Playgroud)
无论我在格式化选项中尝试什么Custom,我总是以尾随零或更改的值结束。
我们在 Vue.js 中使用 Quasar 框架。考虑以下q-card可点击的内容:
<div class="q-pa-md row items-start q-gutter-md cursor-pointer">
  <q-card class="my-card" clickable @click="GetSapRoster">
    <q-card-section class="bg-primary text-white">
      <div class="text-h6">SAP Truck Roster</div>
      <div class="text-subtitle2">Get the truck planning</div>
    </q-card-section>
  </q-card>
</div>
Run Code Online (Sandbox Code Playgroud)
a 怎么可能达到q-card和 a一样的效果q-btn?
在使用类cursor-pointer 时,它只修复了鼠标指针,而不是像 a 一样的阴影效果q-btn。
我正在尝试从字符串中检索IP地址.我绝对不是第一个提出这个问题的人,但我找不到能够完全满足我们需要的答案.
如果字符串中的某个位置是xxx.xxx.xxx.xxx的组合,无论它周围的文本如何,它都应该用中间的点提取这个数字.所以它可以用于Test-Connection.
我不是要确定IP地址是否有效,但我试图从字符串中检索IP地址.即使它是无效的,比如说900.999.800.254.
例:
Input             Expected result
-----             ---------------
IP_10.57.50.91    10.57.50.91
10.57.50.73       10.57.50.73
10.58.4.37 IP     10.58.4.37
ip 10.63.1.22     10.63.1.22
BELPRLIXH300      $False
ip 10.63          $False
Run Code Online (Sandbox Code Playgroud)
 powershell ×7
regex ×2
vue.js ×2
excel ×1
generics ×1
java ×1
javascript ×1
microsoft-distributed-file-system ×1
parameters ×1
parsing ×1
quasar ×1
split ×1
string ×1
syntax ×1
text ×1
typescript ×1