VMware Cloud Community
T180985
Expert
Expert
Jump to solution

Current User

Sorry for the seemingly simple question but i dont seem to be able to find the answer on google. What i need to know is, is it possible to pull the current authenticated users username as a variable without manually setting it? e.g.

PS H:\> $username

PS H:\> T180985


I want to use it as part of a description when creating snapshots

Please mark helpful or correct if my answer resolved your issue. How to post effectively on VMTN https://communities.vmware.com/people/daphnissov/blog/2018/12/05/how-to-ask-for-help-on-tech-forums
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

In that case, use

$global:DefaultVIServer.User


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

Are you referring to a Windows user?
In that case, try using $env:USERNAME

There is also $env:USERDOMAIN


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
T180985
Expert
Expert
Jump to solution

Sorry i should have been more specific, i mean the username ive logged into vCenter with

Please mark helpful or correct if my answer resolved your issue. How to post effectively on VMTN https://communities.vmware.com/people/daphnissov/blog/2018/12/05/how-to-ask-for-help-on-tech-forums
0 Kudos
LucD
Leadership
Leadership
Jump to solution

In that case, use

$global:DefaultVIServer.User


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos