更新时间:2023-02-19 12:40:39
使用正则表达式很简单:
This is simple to do with a regex:
('jsmit123456') -replace '\D+(\d+)','$1'
123456
\D+ = 所有非数字,\d+ = 后面的所有数字.
\D+ = all the non-digits, \d+ = all the digits that follow.
$studentid = $object.SAMAccountName -replace '\D+(\d+)','$1'