{"id":4709,"date":"2025-11-23T13:30:40","date_gmt":"2025-11-23T13:30:40","guid":{"rendered":"https:\/\/geekmungus.co.uk\/?p=4709"},"modified":"2025-11-23T13:31:05","modified_gmt":"2025-11-23T13:31:05","slug":"find-and-change-your-powershell-profile","status":"publish","type":"post","link":"https:\/\/geekmungus.co.uk\/?p=4709","title":{"rendered":"Find and Change your PowerShell Profile"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The PowerShell profile, much like the profile within a Linux Shell session allows you to add\/change things about the session when it starts.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"FindandChangeyourPowerShellProfile-FindProfileLocation\">Find Profile Location<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">By default your profile is stored within your user&#8217;s home directory on your Windows workstation, you can find where it is or where it might be by running:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$profile<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"529\" height=\"37\" src=\"https:\/\/geekmungus.co.uk\/wp-content\/uploads\/2025\/11\/image-8.png\" alt=\"\" class=\"wp-image-4711\" srcset=\"https:\/\/geekmungus.co.uk\/wp-content\/uploads\/2025\/11\/image-8.png 529w, https:\/\/geekmungus.co.uk\/wp-content\/uploads\/2025\/11\/image-8-300x21.png 300w\" sizes=\"auto, (max-width: 529px) 100vw, 529px\" \/><\/figure>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"FindandChangeyourPowerShellProfile-CreatePowerShellProfile\">Create PowerShell Profile<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">If your PowerShell doesn&#8217;t already exist, we can create it, and then we&#8217;ll also add<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>notepad $profile<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You&#8217;ll be prompted to create the file (because it doesn&#8217;t exist), say &#8220;Yes&#8221;.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s just add something so when we open the PowerShell console, we get a greeting:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Microsoft.PowerShell_profile.ps1<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Write-Host \"Welcome Back Commander.....\" -ForeGroundColor Green\nWrite-Host \"Profile: $profile\" -ForeGroundColor DarkGray\nWrite-Host<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now when opening a PowerShell session we get the following output:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"728\" height=\"176\" src=\"https:\/\/geekmungus.co.uk\/wp-content\/uploads\/2025\/11\/image-9.png\" alt=\"\" class=\"wp-image-4712\" srcset=\"https:\/\/geekmungus.co.uk\/wp-content\/uploads\/2025\/11\/image-9.png 728w, https:\/\/geekmungus.co.uk\/wp-content\/uploads\/2025\/11\/image-9-300x73.png 300w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><\/figure>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"FindandChangeyourPowerShellProfile-AddtoPowerShellProfile\">Add to PowerShell Profile<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s say we want to add a new function our profile, so we can just call an Entra Connect Sync on our Entra Connect Sync servers, without having to manually enter all the commands:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Function Start-ADSync {\n\tInvoke-Command -ComputerName HybridServer -ScriptBlock {\n\t\tImport-module adsync\n\t\tStart-adsyncsynccycle -policytype delta\n\t}\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Reference:&nbsp;<a href=\"https:\/\/www.reddit.com\/r\/PowerShell\/comments\/8yclh2\/trying_to_do_a_startadsyncsynccycle_on_remote\/\">https:\/\/www.reddit.com\/r\/PowerShell\/comments\/8yclh2\/trying_to_do_a_startadsyncsynccycle_on_remote\/<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You&#8217;ll need to save your profile file, then re-open the PowerShell session, but then you can just call the Sync to start with the below.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Note your user account will need at least enough permissions on the server to be able to perform administrative tasks.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Start-ADSync<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">And you&#8217;ll get the output:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"597\" height=\"267\" src=\"https:\/\/geekmungus.co.uk\/wp-content\/uploads\/2025\/11\/image-10.png\" alt=\"\" class=\"wp-image-4713\" srcset=\"https:\/\/geekmungus.co.uk\/wp-content\/uploads\/2025\/11\/image-10.png 597w, https:\/\/geekmungus.co.uk\/wp-content\/uploads\/2025\/11\/image-10-300x134.png 300w\" sizes=\"auto, (max-width: 597px) 100vw, 597px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>The PowerShell profile, much like the profile within a Linux Shell session allows you to add\/change things about the session when it starts. Find Profile Location By default your profile is stored within your user&#8217;s home directory on your Windows workstation, you can find where it is or where it might be by running: Create &#8230; <a title=\"Find and Change your PowerShell Profile\" class=\"read-more\" href=\"https:\/\/geekmungus.co.uk\/?p=4709\" aria-label=\"Read more about Find and Change your PowerShell Profile\">Read more<\/a><\/p>\n","protected":false},"author":4,"featured_media":4327,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,60],"tags":[],"class_list":["post-4709","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-microsoft-windows","category-powershell"],"_links":{"self":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/4709","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4709"}],"version-history":[{"count":2,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/4709\/revisions"}],"predecessor-version":[{"id":4714,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/4709\/revisions\/4714"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/media\/4327"}],"wp:attachment":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4709"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4709"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4709"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}