如何执行powershell 脚本

 时间:2026-02-15 22:50:10

1、将下列命令保存为test.vbsSet wmi = GetObject("winmgmts:")Set collection = wmi.ExecQuery("select * from Win32_Process")For Each process in collectionWScript.Echo process.getObjectText_Next

执行 .\test.vbs 会遍历当前Win32进程,并把每个进程的详细信息通过窗口显示出来。

如何执行powershell 脚本

2、怎样让VB脚本的通过控制台输出呢?Wscript //H:CScript怎样还原VB脚本通过窗口输出呢?WScript //H:WScript在powershell中执行VB脚本

PS C:\PS> cscript.exe .test.vbs Microsoft (R) Windows Script Host Version 5.8 Copyright (C) Microsoft Corporation. All rights reserved. instance of Win32_Process {        Caption = "System Idle Process";        CreationClassName = "Win32_Process";        CSCreationClassName = "Win32_ComputerSystem";        CSName = "test-me-01";        Description = "System Idle Process";        Handle = "0";        HandleCount = 0;       

如何执行powershell 脚本

3、 KernelModeTime = "484113379271";        Name = "System Idle Process";        OSCreationClassName = "Win32_OperatingSystem";        OSName = "Microsoft Windows 7 Enterprise |C:Windows|DeviceHarddisk0Partition2";        OtherOperationCount = "0";        OtherTransferCount = "0";        PageFaults = 0;        PageFileUsage = 0;        ParentProcessId = 0;        PeakPageFileUsage = 0;        PeakVirtualSize = "0";        PeakWorkingSetSize = 0;        Priority = 0;        PrivatePageCount = "0";        ProcessId = 0;     

如何执行powershell 脚本

4、   QuotaNonPagedPoolUsage = 0;        QuotaPagedPoolUsage = 0;        QuotaPeakNonPagedPoolUsage = 0;        QuotaPeakPagedPoolUsage = 0;        ReadOperationCount = "0";        ReadTransferCount = "0";        SessionId = 0;        ThreadCount = 2;        UserModeTime = "0";        VirtualSize = "0";        WindowsVersion = "6.1.7601";        WorkingSetSize = "24576";        WriteOperationCount = "0";        WriteTransferCount = "0"; };

如何执行powershell 脚本

5、执行powershell脚本

Powershell拥有自己的脚本,扩展名为“.ps1”

PS C:\PS> echo "dir;Get-PSProvider;help dir" >test.ps1 PS C:\PS> Get-Content ./test.ps1 dir;Get-PSProvider;help dir PS C:\PS> ./test.ps1

初次执行脚本时,可能会碰到一个异常:File ” C:\PS\test.ps1″ cannot be loaded because theexecution of scripts is disabled on this system. Please see“get-help about_signing” for more details.At line:1 char:10+ .test.ps1 <<<<

这是powershell的默认安全设置禁用了执行脚本,要启用这个功能需要拥有管理员的权限。

如何执行powershell 脚本

  • Virtualbox怎么用UEFI+GPT模式安装虚拟机
  • win10在节能计划中怎么设置永不关闭显示器?
  • win10 IE浏览器怎么设置证书目的为服务器验证?
  • 会声会影卡在正在配置Flash player的解决办法
  • 服务器如何整盘备份,服务器定时整盘备份方法
  • 热门搜索
    丽江旅游景点攻略 下面痒痒是怎么回事啊 大熊猫的特点 刺梨可以减肥吗 澳洲旅游 月经期可以减肥吗 武当山旅游攻略 嘴上起水泡怎么办 凉拌猪头肉 健身房跑步机怎么用