-
Recent Posts
- Integrate Full data copy and CDC extract in SQL Server
- Automate jagent/Goldengate monitor agent in windows using powershell – create_ogg_agent_instance
- How to execute SQL jobs only on Primary server when Always-On is used as HA solution – Can you guess second solution?
- How to Safeguard executables you download/install from internet
- Azure SQL Database Copy / Add replication takes forever
Archives
- July 2022 (1)
- October 2021 (1)
- February 2021 (1)
- November 2020 (2)
- October 2020 (1)
- August 2020 (2)
- July 2020 (2)
- June 2020 (3)
- May 2020 (2)
- April 2020 (1)
- March 2020 (3)
- February 2020 (3)
- January 2020 (2)
- October 2019 (1)
- August 2019 (1)
- May 2019 (1)
- April 2019 (1)
- March 2019 (1)
- February 2019 (1)
- January 2019 (1)
- September 2018 (1)
- August 2018 (3)
- July 2018 (3)
- June 2018 (4)
- May 2018 (1)
- April 2018 (1)
- March 2018 (1)
- February 2018 (1)
- January 2018 (1)
- December 2017 (1)
- November 2017 (3)
- September 2017 (2)
- July 2017 (1)
- June 2017 (2)
- May 2017 (1)
- April 2017 (4)
- March 2017 (3)
- February 2017 (4)
- January 2017 (5)
- December 2016 (4)
- November 2016 (3)
- October 2016 (1)
- September 2016 (2)
- August 2016 (3)
- July 2016 (4)
- June 2016 (5)
- May 2016 (3)
- April 2016 (2)
- March 2016 (4)
- February 2016 (5)
- December 2015 (1)
- November 2015 (1)
- September 2015 (2)
- August 2015 (4)
- July 2015 (2)
- June 2015 (4)
- May 2015 (4)
- April 2015 (3)
- March 2015 (7)
- February 2015 (8)
- January 2015 (4)
- December 2014 (5)
- November 2014 (4)
- October 2014 (5)
- September 2014 (9)
- August 2014 (8)
- July 2014 (10)
- June 2014 (8)
- May 2014 (7)
- April 2014 (8)
- March 2014 (6)
- February 2014 (11)
- January 2014 (6)
Categories
Tags
- alwayson
- always on
- Availability Group
- Azure
- AzureSQL
- Backup
- command
- Database size
- data compare
- datetime
- DBAMP
- DMV
- elastic pool
- Error
- error log
- Excel
- Execution Plan
- Failover
- function
- install
- ipconfig
- job
- knowledge
- login
- merge
- microsoft
- monitor
- Mpp Viewer
- MSSQL
- Natively Compiled Stored Procedures
- netstat
- network
- package
- performance
- Permissions
- ping
- Powershell
- productivity
- query
- recursion
- reference
- reset
- restore
- runas
- Salesforce
- Script
- search
- SF_RefreshAll
- SF_Replicate
- Snapshot
- special characters
- sp_msforeachdb
- sql
- sql2014
- sql 2014 new features
- sql configuration
- sql mail
- SQL Server
- SQLServer
- Sql Server 2014 new features
- ssis
- ssms
- ssrs
- STATISTICS IO
- stored procedure
- substring
- tips
- traceflag
- tracert
- transaction
- trigger
- tsql
- useful link
- User Access
- Windows Server
Meta
PowerShell03 – PowerShell script basics
Windows PowerShell script is a collection of Windows PowerShell Cmdlets/Commands. PowerShell scripts can be executed like batch files and it can also be configured to run as scheduled task! I will share few basics to start with PowerShell Scripting…
• PowerShell Scripts needs to be stored with .PS1 extension
• Comments: # is used as first character of a line to comment a line
• Comment multiple lines using
• How to execute PowerShell Script from a command line or Run
○ Powershell “C:\Folder\Fullpath\Script.ps1”
○ -noexit option to see the results
If you execute Powershell Script from Command prompt or Run, PowerShell will be closed after the script execution. Use -noexit option to see the output results, PowerShell windows will not be closed after the execution.
• Execution Policy: This is most common problem for first time users of Powershell Script. By default only remotely signed scripts are allowed to execute, you need to change the execution policy settings.
○ Set-ExecutionPolicy Unrestricted can be used to change the policy and execute all script.
* Learn more about execution policy at https://technet.microsoft.com/en-us/library/hh847748.aspx
Share this:
Related