![]() $host.ui.RawUI.WindowTitle = "Your Text in Windows PowerShell $hostversion - Running as ADMINISTRATOR" $IsAdmin = $NTPrincipal.IsInRole(::Administrator) Here is the code in Profile file: $NTIdentity = ::GetCurrent() Used for: In this example, I have only changed the title of Window PowerShell Console and ISE for both Current User and Administrator. Example 4 – Profile For Both Windows PowerShell Console And ISE As Hosts (All Users – All Hosts) NOTE: Windows PowerShell ISE Imports four models from two profile files ( profile.ps1 and Microsoft.PowerShellISE_profile.ps1 ). Imported Module in Profile file is loaded in the PowerShell ISE environment Usually, value for $HOME is C:\Users\user_name In order for you to find the correct values for variables $HOME and $PSHOME on your installation of PowerShell please run following commands: $HOME ** Run the command from Windows PowerShell ISE console. * Instead of $profile we can use $profile.CurrentUserCurrentHost command. # Profile Type Command Host Profile file name Profile file location 1* Current User, Current Host $profile Console Microsoft.PowerShell_profile.ps1 $HOME\ Documents\WindowsPowerShell\ 2 All Users, Current Host $profile.AllUsersCurrentHost Console Microsoft.PowerShell_profile.ps1 $PSHOME\ 3 Current User, All Hosts $profile.CurrentUserAllHosts Console, ISE Profile.ps1 $HOME\ Documents\WindowsPowerShell\ 4 All Users, All Hosts $profile.AllUsersAllHosts Console, ISE Profile.ps1 $PSHOME\ 5** Current user, Current Host $profile ISE Microsoft.PowerShellISE_profile.ps1 $HOME\ Documents\WindowsPowerShell\ 6** All users, Current Host $profile.AllUsersCurrentHost ISE Microsoft.PowerShellISE_profile.ps1 $PSHOME\ Table 1 - PowerShell Profile types, commands, hosts, file names, file locations
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |