As an example in executing Powershell scripts inside SQL Server or T-SQL stored procedures, I am getting the current data and time using Get-Date CMD code.
EXEC sp_configure 'show advanced options', 1 GO -- To update the currently configured value for advanced options. RECONFIGURE GO -- To enable the feature. EXEC sp_configure 'xp_cmdshell', 1 GO -- To update the currently configured value for this feature. RECONFIGURE GO --create stored procedure CREATE PROCEDURE SP_EXEC_Powershell AS BEGIN EXEC master..xp_cmdshell 'powershell.exe Get-Date' END --Execute StoredProcedure EXEC SP_EXEC_Powershell