PowerShell Eigenschaften und Methoden eines Objektes anzeigen

Um die Eigenschaften und Methoden eines Objektes anzuzeigen gibt es das Kommando: 

get-member
get-member

 

Beispiel:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
PS C:\> cat C:\Windows\System32\drivers\etc\hosts | Get-Member
TypeName: System.String
Name MemberType Definition
---- ---------- ----------
Clone Method System.Object Clone(), System.Object ICloneable.Clone()
CompareTo Method int CompareTo(System.Object value), int CompareTo(string strB), int IComparab...
Contains Method bool Contains(string value)
CopyTo Method void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int co...
EndsWith Method bool EndsWith(string value), bool EndsWith(string value, System.StringCompari...
Equals Method bool Equals(System.Object obj), bool Equals(string value), bool Equals(string...
GetEnumerator Method System.CharEnumerator GetEnumerator(), System.Collections.IEnumerator IEnumer...
GetHashCode Method int GetHashCode()
GetType Method type GetType()
PS C:\> cat C:\Windows\System32\drivers\etc\hosts | Get-Member TypeName: System.String Name MemberType Definition ---- ---------- ---------- Clone Method System.Object Clone(), System.Object ICloneable.Clone() CompareTo Method int CompareTo(System.Object value), int CompareTo(string strB), int IComparab... Contains Method bool Contains(string value) CopyTo Method void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int co... EndsWith Method bool EndsWith(string value), bool EndsWith(string value, System.StringCompari... Equals Method bool Equals(System.Object obj), bool Equals(string value), bool Equals(string... GetEnumerator Method System.CharEnumerator GetEnumerator(), System.Collections.IEnumerator IEnumer... GetHashCode Method int GetHashCode() GetType Method type GetType()
PS C:\>  cat C:\Windows\System32\drivers\etc\hosts | Get-Member


   TypeName: System.String

Name             MemberType            Definition
----             ----------            ----------
Clone            Method                System.Object Clone(), System.Object ICloneable.Clone()
CompareTo        Method                int CompareTo(System.Object value), int CompareTo(string strB), int IComparab...
Contains         Method                bool Contains(string value)
CopyTo           Method                void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int co...
EndsWith         Method                bool EndsWith(string value), bool EndsWith(string value, System.StringCompari...
Equals           Method                bool Equals(System.Object obj), bool Equals(string value), bool Equals(string...
GetEnumerator    Method                System.CharEnumerator GetEnumerator(), System.Collections.IEnumerator IEnumer...
GetHashCode      Method                int GetHashCode()
GetType          Method                type GetType()

 

 

Einfacher PowerShell wrapper

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
@echo off
:: Execute the PS1 file with the same name as this batch file.
set filename=%~d0%~p0%~n0.ps1
if exist "%filename%" (
PowerShell.exe -NoProfile -NonInteractive -NoLogo -ExecutionPolicy Unrestricted -Command "& '%filename%'"
:: Collect the exit code from the PowerShell script.
set err=%errorlevel%
) else (
echo File not found.
echo %filename%
:: Set our exit code.
set err=1
)
:: Pause if we need to.
if [%1] neq [/nopause] pause
:: Exit and pass along our exit code.
exit /B %err%
@echo off :: Execute the PS1 file with the same name as this batch file. set filename=%~d0%~p0%~n0.ps1 if exist "%filename%" ( PowerShell.exe -NoProfile -NonInteractive -NoLogo -ExecutionPolicy Unrestricted -Command "& '%filename%'" :: Collect the exit code from the PowerShell script. set err=%errorlevel% ) else ( echo File not found. echo %filename% :: Set our exit code. set err=1 ) :: Pause if we need to. if [%1] neq [/nopause] pause :: Exit and pass along our exit code. exit /B %err%
@echo off

:: Execute the PS1 file with the same name as this batch file.
set filename=%~d0%~p0%~n0.ps1

if exist "%filename%" (
  PowerShell.exe -NoProfile -NonInteractive -NoLogo -ExecutionPolicy Unrestricted -Command "& '%filename%'"
 
  :: Collect the exit code from the PowerShell script.
  set err=%errorlevel%
) else (
  echo File not found.
  echo %filename%
 
  :: Set our exit code.
  set err=1
)

:: Pause if we need to.
if [%1] neq [/nopause] pause

:: Exit and pass along our exit code.
exit /B %err%

 

Datei: wrapper.txt

Windows 10 Apps De-Installieren

Die folgenden Apps werden deinstalliert:

Get-AppxPackage *3dbuilder* | Remove-AppxPackage
Get-AppxPackage *bingfinance* | Remove-AppxPackage
Get-AppxPackage *bingnews* | Remove-AppxPackage
Get-AppxPackage *bingsports* | Remove-AppxPackage
Get-AppxPackage *candycrushsaga* | Remove-AppxPackage
Get-AppxPackage *connectivitystore* | Remove-AppxPackage
Get-AppxPackage *messaging* | Remove-AppxPackage
Get-AppxPackage *skypeapp* | Remove-AppxPackage
Get-AppxPackage *solitaire* | Remove-AppxPackage
Get-AppxPackage *twitter* | Remove-AppxPackage
Get-AppxPackage *windowsphone* | Remove-AppxPackage
Get-AppxPackage *xbox* | Remove-AppxPackage
Get-AppxPackage *zunemusic* | Remove-AppxPackage
Get-AppxPackage *zunevideo* | Remove-AppxPackage

Eine Liste aller Apps erhalten Sie über den folgenden PowerShell-Befehl:

Get-AppxPackage | Select Name, PackageFullName

Die Apps lassen sich wie folgt wieder installieren:

Get-AppxPackage -AllUsers| Foreach {Add-AppxPackage -DisableDevelopmentMode -Register “$($_.InstallLocation)\AppXManifest.xml”}

PowerShell Skripte ohne Signierung ausführen

PS > Set-ExecutionPolicy remotesigned

Ausführungsrichtlinie ändern
Die Ausführungsrichtlinie trägt zum Schutz vor nicht vertrauenswürdigen Skripts bei. Wenn Sie die Ausführungsrichtlinie
 ändern, sind Sie möglicherweise den im Hilfethema "about_Execution_Policies" beschriebenen Sicherheitsrisiken
ausgesetzt. Möchten Sie die Ausführungsrichtlinie ändern?
[J] Ja  [N] Nein  [H] Anhalten  [?] Hilfe (Standard ist "J"): j
PS >