Introduction
Tip
The content is available in English and Russian. You can use the language switch in the top toolbar of this website (to the left from the search box) to change language.
This documentation project is based on the blog post series by Matt Graeber:
- Use PowerShell to Interact with the Windows API: Part 1
- Use PowerShell to Interact with the Windows API: Part 2
- Use PowerShell to Interact with the Windows API: Part 3
Here you can find tutorials and examples on how to access the Windows API (formerly called the Win32 API) from PowerShell scripts. Tutorials consider three alternative ways of calling the CopyFile function, and demonstrate the creation of a PowerShell module with the Copy-RawItem
cmdlet. The custom cmdlet differs from the standard Copy-Item, as it can handle special device object paths, such as paths to files backed up by the Volume Shadow Copy Service:
\\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1_
Handling of errors thrown by the called Windows API method is also demonstrated.
Tip
Accessing CopyFile
is considered as a simple basic example here. You can use a similar approach to access other Windows APIs
Contents
Note
Several sections are not completed yet, the content is under development.
Code Examples
Examples demonstrated in this documentation are available an GitHub: powershell-winapi-tutorial/examples/.