> ## Content Index
> Fetch the complete content index at: https://nolongerset.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# 4 VBA PowerShell Functions
- URL: https://nolongerset.com/vba-powershell-functions/
- Published: 2021-10-24T00:00:46.000Z
- Updated: 2026-05-08T13:01:42.000Z
- Description: Microsoft Access MVP Daniel Pineault provides four easy-to-use routines for integrating PowerShell with VBA.
- Author: Mike Wolfe
- Tags: Intermediate, #Import 2026-05-20 02:59

PowerShell is Microsoft's powerful scripting language that provides easy access to the full .NET framework. 

It's indispensable for automating certain Microsoft 365 tasks, in particular anything having to do with Microsoft Exchange Online. Unfortunately, there is nothing built in to the standard VBA library to interact with PowerShell. Luckily for us, Microsoft Access MVP [Daniel Pineault](https://www.devhut.net/about-daniel-pineault/) has written a [series of functions](https://www.devhut.net/vba-run-powershell-command/) to make working with PowerShell from VBA much easier.

Here's a brief description of each function:

- `PS_Execute(ByVal sPSCmd As String)`: runs a PowerShell command. Use this when you don't care about the return value.
- `PS_GetOutput(ByVal sPSCmd As String) As String`: runs a PowerShell command and returns the output as a string. Use this when you need the return value.
- `PS_Admin_Execute(ByVal sPSCmd As String)`: runs a PowerShell command with elevated rights. Use this for tasks that require admin privileges. You will receive the typical UAC prompt.
- `PS_Admin_GetOutput(ByVal sPSCmd As String)`: runs a PowerShell command with elevated rights and returns the output as a string. Use this for admin tasks where you need the return value.

One of the nice things about these functions is that they use late binding, so they require no extra references.

### External references

[VBA - Run PowerShell Command | DEVelopers HUTA couple examples of how you can execute a PowerShell command through VBA a retrieve the response.DEVelopers HUTDaniel Pineault](https://www.devhut.net/vba-run-powershell-command/)

[About Daniel Pineault | DEVelopers HUTA little bit about Daniel Pineault.DEVelopers HUT<img src=“https://www.devhut.net/wp-content/plugins/author-profile/images/home.png” title=“Homepage” alt=“Homepage” />](https://www.devhut.net/about-daniel-pineault/)

*Image by [Schäferle](https://pixabay.com/users/schäferle-3372715/?utm%5Fsource=link-attribution&utm%5Fmedium=referral&utm%5Fcampaign=image&utm%5Fcontent=2037255) from [Pixabay](https://pixabay.com/?utm%5Fsource=link-attribution&utm%5Fmedium=referral&utm%5Fcampaign=image&utm%5Fcontent=2037255)*