Team Ai
Datasetpublic

MegaBites-AI/Windows-powershell

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes372downloads
FAQ.md117 linesDownload Raw Back to docs
1# Frequently Asked Questions2 3## Where can I learn PowerShell's syntax?4 5- [What is PowerShell?][12]6- [Discover PowerShell][09]7- [PowerShell 101][11]8- [PowerShell learning resources][10]9 10## What are the best practices and styles?11 12The [PoshCode][03] unofficial guide is our reference.13 14## What are PowerShell's scoping rules?15 16- Variables are created in your current scope unless explicitly indicated.17- Variables are visible in a child scope unless explicitly indicated.18- Variables created in a child scope are not visible to a parent unless explicitly indicated.19- Variables may be placed explicitly in a scope.20 21### Things that create a scope22 23- [about_Functions_Advanced][04]24- [about Operators - Call operator][06] (`& { }`)25- [about Scopes][08]26 27### Things that operate in the current scope28 29- [about Operators - Dot source operator][07] (`. { }`)30- [about Language Keywords][05] (`if .. else`, `for`, `switch`, etc.)31 32## Why didn't an error throw an exception?33 34Error handling in PowerShell is unique, as not all errors result in catchable exceptions by default.35Setting `$ErrorActionPreference = 'Stop'` will likely do what you want; that is, cause36non-terminating errors instead of terminating. Read the [GitHub issue][02] for more information.37 38## Where do I get the PowerShell Core SDK package?39 40The SDK NuGet package **Microsoft.PowerShell.SDK** is provided for developers to write C# code41targeting PowerShell. PowerShell NuGet packages are published to [Microsoft.PowerShell.SDK][13] on42NuGet.org.43 44To use the `Microsoft.PowerShell.SDK` NuGet package, declare `PackageReference` tags in your45`.csproj` file as follows:46 47```xml48<ItemGroup>49  <PackageReference Include="Microsoft.PowerShell.SDK" Version="7.3.5" />50  <PackageReference Include="Microsoft.PowerShell.Commands.Diagnostics" Version="7.3.5" />51  <PackageReference Include="Microsoft.WSMan.Management" Version="7.3.5"/>52</ItemGroup>53```54 55## Why did my build fail?56 57There are few common issues with the build. The easiest way to resolve most issues with the build is58to run `Start-PSBuild -Clean`.59 60### Dependency changed61 62If package dependencies were changed in any `project.json`, you need to manually run63`dotnet restore` to update your local dependency graphs. `Start-PSBuild -Restore` can automatically64do this.65 66### Resource changed67 68`Start-PSBuild` automatically calls `Start-ResGen` on the very first run. On subsequent runs, you69may need to explicitly use `Start-PSBuild -ResGen` command.70 71Try it, when you see compilation error about *strings.72 73[More details][01] about resource.74 75### TypeGen76 77Similar to `-ResGen` parameter, there is `-TypeGen` parameter that triggers regeneration of type78catalog.79 80## Why did `Start-PSBuild` tell me to update `dotnet`?81 82We depend on the latest version of the .NET CLI, as we use the output of `dotnet --info` to83determine the current runtime identifier. Without this information, our build function can't know84where `dotnet` is going to place the build artifacts.85 86You can automatically install this using `Start-PSBootstrap`.87**However, you must first manually uninstall other versions of the CLI.**88 89If you have installed by using any of the following means:90 91- `MSI`92- `exe`93- `apt-get`94- `pkg`95 96You *must* manually uninstall it.97 98Additionally, if you've just unzipped their binary drops (or used their obtain scripts, which do99essentially the same thing), you must manually delete the folder, as the .NET CLI team re-engineered100how their binaries are setup, such that new packages' binaries get stomped on by old packages'101binaries.102 103<!-- updated link references -->104[01]: dev-process/resx-files.md105[02]: https://github.com/MicrosoftDocs/PowerShell-Docs/issues/1583106[03]: https://github.com/PoshCode/PowerShellPracticeAndStyle107[04]: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_functions_advanced108[05]: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_language_keywords109[06]: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_operators#call-operator-110[07]: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_operators#dot-sourcing-operator-111[08]: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_scopes112[09]: https://learn.microsoft.com/powershell/scripting/discover-powershell113[10]: https://learn.microsoft.com/powershell/scripting/learn/more-powershell-learning114[11]: https://learn.microsoft.com/powershell/scripting/learn/ps101/00-introduction115[12]: https://learn.microsoft.com/powershell/scripting/overview116[13]: https://www.nuget.org/packages/Microsoft.PowerShell.SDK117