{"id":7924,"date":"2021-11-11T19:49:13","date_gmt":"2021-11-11T18:49:13","guid":{"rendered":"https:\/\/michlstechblog.info\/blog\/?p=7924"},"modified":"2021-11-12T11:49:19","modified_gmt":"2021-11-12T10:49:19","slug":"powershell-run-a-init-script-when-powershell-starts","status":"publish","type":"post","link":"https:\/\/michlstechblog.info\/blog\/powershell-run-a-init-script-when-powershell-starts\/","title":{"rendered":"Powershell: Run a (init) script when powershell starts"},"content":{"rendered":"<div class=\"twoclick_social_bookmarks_post_7924 social_share_privacy clearfix 1.6.4 locale-en_US sprite-en_US\"><\/div><div class=\"twoclick-js\"><script type=\"text\/javascript\">\/* <![CDATA[ *\/\njQuery(document).ready(function($){if($('.twoclick_social_bookmarks_post_7924')){$('.twoclick_social_bookmarks_post_7924').socialSharePrivacy({\"services\":{\"flattr\":{\"uid\":\"Michl\",\"status\":\"on\",\"the_title\":\"Powershell%3A%20Run%20a%20%28init%29%20script%20when%20powershell%20starts\",\"the_excerpt\":\"Hi%2C%0D%0A%0D%0Aif%20have%20some%20own%20aliases%20or%20functions%20defined%20which%20should%20be%20loaded%20when%20powershell%20starts%20you%20can%20create%20a%20startup%20script.%0D%0A%20%28more%26hellip%3B%29\",\"txt_info\":\"2 clicks for more data protection:\\r\\n\\r\\nOnly when you click here, the button will be come active and you can send your recommendation to Flattr. When activating, data are transmitted to third parties. \",\"perma_option\":\"off\"}},\"txt_help\":\"When you activate these fields by clicking, information to Flattr may be transferred abroad, and probably may also stored there.\",\"settings_perma\":\"Enable permanently and accept data transmission. \",\"info_link\":\"http:\\\/\\\/www.heise.de\\\/ct\\\/artikel\\\/2-Klicks-fuer-mehr-Datenschutz-1333879.html\",\"uri\":\"https:\\\/\\\/michlstechblog.info\\\/blog\\\/powershell-run-a-init-script-when-powershell-starts\\\/\",\"post_id\":7924,\"post_title_referrer_track\":\"Powershell%3A+Run+a+%28init%29+script+when+powershell+starts\",\"display_infobox\":\"on\"});}});\n\/* ]]> *\/<\/script><\/div><p>Hi,<\/p>\n<p>if have some own aliases or functions defined which should be loaded when powershell starts you can create a startup script.<br \/>\n<!--more--><br \/>\n<!-- https:\/\/docs.microsoft.com\/de-de\/powershell\/module\/microsoft.powershell.core\/about\/about_profiles?view=powershell-7.2 --><br \/>\nDetermine the best the script which fits your needs best <\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\nPS D:\\&gt; Get-Member -InputObject $PROFILE -Type NoteProperty\r\n   TypeName: System.String\r\n\r\nName                   MemberType\r\n----                   ----------\r\nAllUsersAllHosts       NoteProperty\r\nAllUsersCurrentHost    NoteProperty\r\nCurrentUserAllHosts    NoteProperty\r\nCurrentUserCurrentHost NoteProperty\r\n\r\nPS D:\\ Get-Member -InputObject $PROFILE -Type NoteProperty | %{$PROFILE.($_.Name)}\r\nC:\\Windows\\System32\\WindowsPowerShell\\v1.0\\profile.ps1\r\nC:\\Windows\\System32\\WindowsPowerShell\\v1.0\\Microsoft.PowerShell_profile.ps1\r\nC:\\Users\\michael\\Documents\\WindowsPowerShell\\profile.ps1\r\nC:\\Users\\michael\\Documents\\WindowsPowerShell\\Microsoft.PowerShell_profile.ps1\r\n<\/pre>\n<p>Crete one  of those script files and places your code into it.<\/p>\n<p>Michael<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi, if have some own aliases or functions defined which should be loaded when powershell starts you can create a startup script.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[344,5,4],"tags":[1648,133,912,1649,1650,20],"class_list":["post-7924","post","type-post","status-publish","format-standard","hentry","category-powershell-scripting","category-windowsknowhow","category-windowsscripts","tag-autoexec","tag-powershell","tag-profile","tag-startup","tag-startup-script","tag-windows-2"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/7924","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/comments?post=7924"}],"version-history":[{"count":3,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/7924\/revisions"}],"predecessor-version":[{"id":7927,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/7924\/revisions\/7927"}],"wp:attachment":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/media?parent=7924"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/categories?post=7924"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/tags?post=7924"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}