我写了一个小脚本,但我想知道这是否是使用PowerShell从Active Directory中提取MobilePhone
属性的正确方法?
$csvfi = import-csv "C:\Users\\Documents\users.csv"
foreach($row in $csvfi)
{
$cellphone = $row.Phone
$fullname = $row.Name
$adphone = (Get-ADUser -Filter "Name -eq '$fullname'" -Properties * | Select MobilePhone).MobilePhone
Write-Host $fullname, $adphone
}
执行-Filter
,然后-Properties *
,然后导管到Select
然后从该对象获取.MobilePhone
属性似乎很麻烦。
作为旁注,我只需要来自AD的原始移动电话号码,1-AAA-NNN-NNNN,这样我就可以将其与电子表格users.csv
中的手机号码进行比较。
答案 0 :(得分:1)
var str = "Some text <img src='http://www.domainname.com/people2/images/somefilename1.jpeg' alt=''width='100' style='border:none;' /> more text.\
Even more text <img src='http://www.domainname.com/people2/images/somefilename2.jpg' alt=''width='100' style='border:none;' /> and so on.\
Third line now, and more text <img src='http://www.domainname.com/people2/images/somefilename3.png' alt=''width='100' style='border:none;' /> with extra image <img src='http://www.domainname.com/people2/images/somefilename4.png' alt=''width='100' style='border:none;' /> and text.";
var re = /<img.*?\/images\/([^'"]+).*?/gm, m,
result = "";
while ((m = re.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === re.lastIndex) {
re.lastIndex++;
}
result += ' ' + m[1];
}
console.log(result);