{"id":76384,"date":"2024-11-25T01:58:22","date_gmt":"2024-11-25T01:58:22","guid":{"rendered":"http:\/\/bangla.sitestree.com\/?p=76384"},"modified":"2024-12-04T03:47:41","modified_gmt":"2024-12-04T03:47:41","slug":"misc-on-power-shell-script","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=76384","title":{"rendered":"Misc. on Power Shell Script"},"content":{"rendered":"\n<p><strong>Misc. on Power Shell Script<\/strong><\/p>\n\n\n\n<p>How to read data from users?<\/p>\n\n\n\n<p><strong>Read-Host<\/strong><\/p>\n\n\n\n<p>How to write\/print output data\/text to the user:<\/p>\n\n\n\n<p><strong>Write-Output<\/strong><\/p>\n\n\n\n<p>How to Check if a file exists?<\/p>\n\n\n\n<p><strong>Test-Path $filePath<\/strong><\/p>\n\n\n\n<p>How to append data to a file?<\/p>\n\n\n\n<p><strong>Add-Content -Path $filePath -Value &#8220;x: $x, y: $y&#8221;<\/strong><\/p>\n\n\n\n<p>How to create a file?<\/p>\n\n\n\n<p><strong>New-Item -Path $filePath -ItemType File -Force<\/strong><\/p>\n\n\n\n<p>How to write content to a file?<\/p>\n\n\n\n<p><strong>Set-Content -Path $filePath -Value &#8220;x: $name, y: $age&#8221;<\/strong><\/p>\n\n\n\n<p>How to get a list of all files in a directory<\/p>\n\n\n\n<p><strong>$files = Get-ChildItem -Path $dirPath<\/strong><\/p>\n\n\n\n<p>How to find the size of a file?<\/p>\n\n\n\n<p><strong>$file.Length<\/strong><\/p>\n\n\n\n<p>How to append content to a file?<\/p>\n\n\n\n<p><strong>$content | Out-File -FilePath $outputFile -Append <\/strong><\/p>\n\n\n\n<p>How to Create a file and write content to it?<\/p>\n\n\n\n<p><strong>$content | Out-File -FilePath $outputFile<\/strong><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Misc. on Power Shell Script How to read data from users? Read-Host How to write\/print output data\/text to the user: Write-Output How to Check if a file exists? Test-Path $filePath How to append data to a file? Add-Content -Path $filePath -Value &#8220;x: $x, y: $y&#8221; How to create a file? New-Item -Path $filePath -ItemType File &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=76384\">Continue reading<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1968,1,1345],"tags":[],"class_list":["post-76384","post","type-post","status-publish","format-standard","hentry","category-operating-systems","category-root","category----operating-systems","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":69884,"url":"http:\/\/bangla.sitestree.com\/?p=69884","url_meta":{"origin":76384,"position":0},"title":"Razor, Web-page Model, Web-Application Development in C# #19","author":"Author-Check- Article-or-Video","date":"August 21, 2021","format":false,"excerpt":"Razor, Web-page Model, Web-Application Development in C# Razor: a markup syntax to add server side code into ASP.net pages Razor example: Current time is @DateTime.Now Razor Code Syntax Single statement block @{ var message = \"Hello World\"; } Inline expression or variable The message: @message Multi-statement block @{ var greeting\u2026","rel":"","context":"In &quot;C# - Misc&quot;","block_context":{"text":"C# - Misc","link":"http:\/\/bangla.sitestree.com\/?cat=1973"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":70285,"url":"http:\/\/bangla.sitestree.com\/?p=70285","url_meta":{"origin":76384,"position":1},"title":"Razor, Web-page Model, Web-Application Development in C# #.Net Web Applications","author":"Author-Check- Article-or-Video","date":"August 31, 2021","format":false,"excerpt":"Brought from: http:\/\/salearningschool.com\/displayArticle.php?table=Articles&articleID=1320&title=Razor,%20Web-page%20Model,%20Web-Application%20Development%20in%20C# (written long back) Razor, Web-page Model, Web-Application Development in C# Razor:a markup syntax to add server side code into ASP.net pages Razor example: Current time is @DateTime.Now Razor Code Syntax Single statement block @{ var message = \"Hello World\"; } Inline expression or variable The message: @message\u2026","rel":"","context":"In &quot;C# - Misc&quot;","block_context":{"text":"C# - Misc","link":"http:\/\/bangla.sitestree.com\/?cat=1973"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":17008,"url":"http:\/\/bangla.sitestree.com\/?p=17008","url_meta":{"origin":76384,"position":2},"title":"Python: Ecommerce: Part \u2014 7: Partition a Data File (with product information) into Multiple Files.","author":"Sayed","date":"April 19, 2020","format":false,"excerpt":"In previous steps, we created a product data file to be uploaded to Magento 2 (from supplier data). However, there is a limit, how big a file can be uploaded to Magento 2 for product data import. Hence, this code will divide the data file into multiple files. This data\u2026","rel":"","context":"In &quot;Build Ecommerce Software&quot;","block_context":{"text":"Build Ecommerce Software","link":"http:\/\/bangla.sitestree.com\/?cat=1912"},"img":{"alt_text":"8112223 Canada Inc. (Justetc)","src":"https:\/\/miro.medium.com\/fit\/c\/80\/80\/0*P_esmjKoJnHlNjFX","width":350,"height":200},"classes":[]},{"id":65718,"url":"http:\/\/bangla.sitestree.com\/?p=65718","url_meta":{"origin":76384,"position":3},"title":"On Thursday and Friday tar all contents of \/etc folder into \/export\/home\/shell\/test\/etc.tar .. do misc logs #Linux\/Unix: Shell Programming &#8211; 001","author":"Author-Check- Article-or-Video","date":"July 12, 2021","format":false,"excerpt":"#!\/bin\/ksh # on every thursday and friday tar all contents of \/etc folder into \/export\/home\/shell\/test\/. On thursday only create a log file with the list of files #in the tar file. On thursday untar \/export\/home\/shell\/test\/etc.tar into vfstab . Then log vfstab exist or not information DAY=`date +%a` DATESTAMP=`date +%m-%d-%Y-%H:%M` if\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65656,"url":"http:\/\/bangla.sitestree.com\/?p=65656","url_meta":{"origin":76384,"position":4},"title":"Debug and Trace classes in .Net #Misc .Net","author":"Author-Check- Article-or-Video","date":"July 10, 2021","format":false,"excerpt":"Brought from our old-site (yes, pretty old short-note): http:\/\/salearningschool.com\/displayArticle.php?table=Articles&articleID=636&title=Debug%20and%20Trace%20Classes%20in%20.Net Debug and Trace classes in .Net You can always debug your applications line by line. However, when the applications get very bigger\/larger, debugging line by line may not be an efficient way for finding errors in code (well, you can first\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65677,"url":"http:\/\/bangla.sitestree.com\/?p=65677","url_meta":{"origin":76384,"position":5},"title":"Debugging in .Net, (XML Web Services) #Misc .Net","author":"Author-Check- Article-or-Video","date":"July 11, 2021","format":false,"excerpt":"Brought from: http:\/\/salearningschool.com\/displayArticle.php?table=Articles&articleID=1117&title=Debugging%20in%20.Net,%20(XML%20Web%20Services) Just listing some related notes. Tools: DbgClr -GUI Based, CorDbg - command line based You can use the debug menu. Start, Step Into, Step Over, New Breakpoint options - as available in most Good to great IDEs for debugging Watch Window: Check the values of variables and\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/76384","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=76384"}],"version-history":[{"count":1,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/76384\/revisions"}],"predecessor-version":[{"id":76385,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/76384\/revisions\/76385"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=76384"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=76384"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=76384"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}