cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How to run Powershell file script.ps1 using the databricks notebook

sandeephenkel23
New Contributor II

Hello All,

Following command on running through databricks notebook is not working 

Command

%sh
# Bash code to print 'Hello, PowerShell!'
echo 'Hello, PowerShell!'
# powershell.exe -ExecutionPolicy Restricted -File /dbfs:/FileStore/Read_Vault_Inventory.ps1
 
It;s throwing the following error:
output
Hello, PowerShell!
bash: line 3: powershell.exe: command not found
 
Kindly give some insights how to run the .ps1 file stored in dbfs file store or how to run the powershell commands through databricks notebook
2 REPLIES 2

Kaniz
Community Manager
Community Manager

Hi @sandeephenkel23, To run PowerShell commands in Databricks, you might need to use a different approach. 

 

Here are a few options:

 

Azure Cloud Shell: Azure hosts Azure Cloud Shell, an interactive shell environment you can use through your browser. You can use either Bash or PowerShell with Cloud Shell to work with Azure services.

Databricks API: You can call the Databricks API from PowerShell. This might involve managing Azure Active Directory Service Principals and Groups within Databricks.

PowerShell Module for Databricks: Thereโ€™s a PowerShell module for Databricks that works on Azure and.... You can install it using the Install-Module cmdlet, set up the Databricks environment using the API ....

 

Please note that these methods might not allow you to directly run a .ps1 file stored in the DBFS file store. You might need to refactor your PowerShell script into API calls or cmdlets that are compatible with the methods above.

 

Always follow the best practices and guidelines when working with Databricks Notebooks. If you have any more questions or need further assistance, feel free to ask! ๐Ÿ˜Š

Kaniz
Community Manager
Community Manager

Thank you for posting your question in our community! We are happy to assist you.

To help us provide you with the most accurate information, could you please take a moment to review the responses and select the one that best answers your question?

This will also help other community members who may have similar questions in the future. Thank you for your participation and let us know if you need any further assistance! 
 

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.