powershell
黑兔子JH
heituzi_jh@163.com
展开
-
改变powershell执行权限
1.在脚本文件中:powershell -noprofile Set-ExecutionPolicy Unrestricted2.在powershell窗口中:1)获取当前权限:2)设置权限:原创 2018-07-19 16:19:23 · 6519 阅读 · 0 评论 -
powershell脚本设置电脑分辨率
Function Set-Resolution{ param ( [Parameter(Mandatory = $true, Position = 0)] [int] $Width, [Parameter(Mandatory = $true, Position = 1)] [int] $Height ) #设置分辨率...原创 2018-07-23 10:29:59 · 4136 阅读 · 0 评论 -
powershell脚本设置电脑音量
Function Set-Volume{ param ( [Parameter(Mandatory = $true, Position = 0)] [int] $SndVol ) #设置音量 $TypeDefinition = @" using System; using System.Runtime.Inter...原创 2018-07-23 10:30:14 · 2153 阅读 · 1 评论 -
powershell脚本实现计算机加入域
Function Set-Domain{ param ( [Parameter(Mandatory = $true, Position = 0)] [string] $DNS, [Parameter(Mandatory = $true, Position = 1)] [string] $Domain, [Parameter(...原创 2018-07-23 10:30:22 · 6204 阅读 · 0 评论 -
powershell脚本设置网络
Function Set-Network{ param ( [Parameter(Mandatory = $true, Position = 0)] [string] $IPAddress, [Parameter(Mandatory = $true, Position = 1)] [string] $NetMask, [Parame...原创 2018-07-19 16:36:26 · 1455 阅读 · 0 评论 -
powershell脚本设置计算机名
Function Set-ComputerName{ param ( [Parameter(Mandatory = $true, Position = 0)] [string] $ComputerName ) $computer=Get-WMIObject Win32_ComputerSystem #设置计算机名 $...原创 2018-07-19 16:35:21 · 2626 阅读 · 0 评论 -
powershell执行脚本中的函数找不到函数
import-module C:\Windows\System32\WindowsPowerShell\v1.0\Functions.ps1需要先执行上面这句话,再调用脚本中的函数原创 2018-07-19 16:32:18 · 1487 阅读 · 0 评论 -
powershell脚本获取电脑分辨率
add-type -AssemblyName System.Windows.Forms$CWidth = (([System.Windows.Forms.Screen]::PrimaryScreen).Bounds).Width$CHeight = (([System.Windows.Forms.Screen]::PrimaryScreen).Bounds).Height原创 2018-07-19 16:29:01 · 2208 阅读 · 0 评论 -
powershell脚本获取DNS
$wmi = Get-WmiObject win32_networkadapterconfiguration -filter "ipenabled = 'true'"$CDNS = $wmi.DNSServerSearchOrder原创 2018-07-19 16:28:07 · 1550 阅读 · 0 评论 -
powershell脚本获取当前网关
$wmi = Get-WmiObject win32_networkadapterconfiguration -filter "ipenabled = 'true'"$CGate = $wmi.DefaultIPGateway原创 2018-07-19 16:26:42 · 1634 阅读 · 0 评论 -
powershell脚本获取当前IPv4地址
$wmi = Get-WmiObject win32_networkadapterconfiguration -filter "ipenabled = 'true'"$CIP = $wmi.IPAddress -notlike "*:*"原创 2018-07-19 16:25:39 · 1895 阅读 · 0 评论 -
powershell脚本获取当前计算机名
$computer=Get-WMIObject Win32_ComputerSystem $Cname = $computer.name原创 2018-07-19 16:24:13 · 4326 阅读 · 0 评论 -
powershell脚本获取电脑当前音量值
$TypeDefinition = @" using System; using System.Runtime.InteropServices; namespace Sound { [Guid("5CDF2C82-841E-4546-9722-0CF74078229A"), InterfaceType(ComInterfaceType.Inter...原创 2018-07-19 16:21:56 · 1463 阅读 · 0 评论 -
捕获powershell报错信息
官网介绍的路径:https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_try_catch_finally?view=powershell-61.Try, Catch, and Finally 1)捕获到错误,并打印“Error:配置域失败”try{...原创 2018-07-30 16:56:24 · 816 阅读 · 0 评论