2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

はじめに

Windowsのフルネームを取得するのが、ユーザー名と同じノリと思ってたら意外と苦戦したので、
記録として残します。

赤枠で囲っているところが今回取得したいフルネームです。

image.png

実際にやってみた

今回の実装

くどいようですがもう一度載せます。

$dom = $env:userdomain
$usr = $env:username
([adsi]"WinNT://$dom/$usr,user").fullname

実行結果

PS C:\Users\xxxx> $dom = $env:userdomain
$usr = $env:username
([adsi]"WinNT://$dom/$usr,user").fullname
たんすけ

無事にフルネームが取得できました。

参考文献

UiPathでやっている方もいました。

おわりに

そんなに難しい話ではないかなと思っていたのですが、意外と苦戦しました。

今後もこういった意外と難しかったシリーズを取り上げられたらなと思います。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?