PowerShell:
<new view command here> | ForEach-Object {$_.TrimStart('\')}
質問
When I run the net view
command, it will output similar to the following:
\\C66423
\\C66424
\\C66425
\\C66426
\\C66427
\\C66428
\\C66429
\\C66430
\\C66432
\\C66433
What I would like to know is if it is possible to trim out the \\
before each computer name?
解決
PowerShell:
<new view command here> | ForEach-Object {$_.TrimStart('\')}
他のヒント
setlocal enabledelayedexpansion
for /f %%a in ('net view') do (
set "string=%%a"
echo !string:~2!
)
should do the trick (untested)
Similar to Magoo's answer but without the need for string manipulation, and therefore delayed expansion:
@echo off
for /f "delims=\" %%a in ('net view') do echo %%a
You could also add skip=2
to the for command to remove the first couple of lines of output - which is:
Server Name Remark
-------------------------------