随笔分类 -  PowerShell

1 2 3 4 5 ··· 14 下一页
PowerShell发送企业微信消息
摘要:参考:https://developer.work.weixin.qq.com/document/path/90372#%E6%96%87%E6%9C%AC%E5%8D%A1%E7%89%87%E6%B6%88%E6%81%AF 发送文本类型消息 Import-Module Microsoft.Po 阅读全文
posted @ 2024-07-12 11:18 momingliu11 阅读(15) 评论(0) 推荐(0) 编辑
PowerCli监控Esxi硬件状态
摘要:#在CentOS上安装powershell-lts-7.0.1-1.rhel.7.x86_64.rpm #然后将VMware-PowerCLI-12.4.1-18769701.zip解压后拷贝到/opt/microsoft/powershell/7-lts/Modules/目录下 Connect-V 阅读全文
posted @ 2024-05-21 15:30 momingliu11 阅读(23) 评论(0) 推荐(0) 编辑
通过nssm将PowerShell脚本注册为系统服务
摘要:登录Http://nssm.cc下载nssm程序 #将PowerShell脚本安装为Windows服务 $ServiceName = "GetUser" #指定服务名称 $PSPath = (Get-Command powershell).Source $PSScriptPath = "D:\Ope 阅读全文
posted @ 2024-03-15 10:03 momingliu11 阅读(80) 评论(0) 推荐(0) 编辑
获取本地用户及其所属组
摘要:$Res_Path = "d:\temp\" $Time = Get-Date -UFormat "%Y%m%d%H%M" $ComputerName = $env:computername $IP = ((gwmi win32_networkadapterconfiguration | ? {$_ 阅读全文
posted @ 2023-10-17 17:12 momingliu11 阅读(18) 评论(0) 推荐(0) 编辑
Exchange批量删除邮件
摘要:Add-PSSnapin microsoft.exchange* $Subject = '警惕“退税”钓鱼邮件' #如果主题中包含&符号等特殊字符,则使用三对单引号 $From = "it@yx.com" $Sent = "05/09/2023" $Search = "Sent>=$Sent AND 阅读全文
posted @ 2023-05-10 17:28 momingliu11 阅读(153) 评论(0) 推荐(0) 编辑
获取元素所在数组位置
摘要:[array]::indexof($array,‘bbb’) 参考:https://devblogs.microsoft.com/scripting/find-the-index-number-of-a-value-in-a-powershell-array/ 阅读全文
posted @ 2023-03-30 17:59 momingliu11 阅读(23) 评论(0) 推荐(0) 编辑
将变量值作为变量名称
摘要:$groupnum=@('d1','d2') $var_mid="groupnum" + $groupnum[0]New-Variable -Name $var_mid -Value 3 Get-Variable $var_mid $groupnumd1值为3 阅读全文
posted @ 2023-03-30 16:49 momingliu11 阅读(52) 评论(0) 推荐(0) 编辑
使用psftp管理ftp上传下载
摘要:#安装PSFTP模块 Install-Module psftp Get-Module psftp -ListAvailable Import-Module psftp $UserName = "ftpuser" $Password = "ftppassword" $userPassword = Co 阅读全文
posted @ 2023-03-10 15:22 momingliu11 阅读(111) 评论(0) 推荐(0) 编辑
定时同步和定时备份xcopy
摘要:每天定时同步数据 #脚本功能: #该脚本用来从远程服务器同步文件,会对文件修改时间进行比较,如果远程文件修改时间不小于当前服务器文件修改时间,则进行拷贝 #远程源文件夹不要包含有子目录 $remote_ip = "10.10.22.34" $username = "test\administrato 阅读全文
posted @ 2022-06-29 11:40 momingliu11 阅读(321) 评论(0) 推荐(0) 编辑
查询3天内创建邮箱的用户
摘要:查询3天内创建邮箱的用户 $d = (Get-Date).adddays(-3) $ys = Get-ADUser -Filter 'Enabled -eq $true -and msExchWhenMailboxCreated -ne "$null" -and msExchWhenMailboxC 阅读全文
posted @ 2022-06-28 14:02 momingliu11 阅读(38) 评论(0) 推荐(0) 编辑
IIS新建站点、配置应用程序池
摘要:#新建IIS站点,设置主机头,设置应用程序池 $domainname = "domainname" $site_oa = "OA" $site_oa_dir = "d:\$site_oa" $url_owa = ($site_oa + "." + $domainname).ToLower() New 阅读全文
posted @ 2022-06-28 11:27 momingliu11 阅读(309) 评论(0) 推荐(0) 编辑
PowerCLi获取宿主和虚机性能信息
摘要:#该脚本用来根据csv定义的信息批量创建虚机 $vc = "vc.y.com" $user = "ZabbixMonitor@vc.com" #只读账号即可 $password = "Mpassword" Set-PowerCLIConfiguration -InvalidCertificateAc 阅读全文
posted @ 2022-01-19 17:32 momingliu11 阅读(281) 评论(0) 推荐(0) 编辑
PowerShell操纵MySQL
摘要:#导入操作MySQL库 $mySQLDataDLL = "C:\Scripts\GetMonitor\MySQL.Data.dll" [void][system.reflection.Assembly]::LoadFrom($mySQLDataDLL) #定义连接MySQL相关信息 $Server= 阅读全文
posted @ 2021-12-07 17:13 momingliu11 阅读(298) 评论(0) 推荐(0) 编辑
PowerShell远程管理SCVMM
摘要:#连接到SCVMM Import-Module virtualmachinemanager Get-VMMServer (gwmi win32_computersystem).Name |Out-Null #查询Hyper-V宿主总数 $hvs = Get-SCVmhost #查询虚拟机总数 $vm 阅读全文
posted @ 2021-12-07 10:24 momingliu11 阅读(95) 评论(0) 推荐(0) 编辑
重命名计算机账户密码
摘要:Get-ADComputer "GONGDAN" | Set-ADAccountPassword -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "Zmfad3" -Force) 阅读全文
posted @ 2021-06-04 11:13 momingliu11 阅读(128) 评论(0) 推荐(0) 编辑
导入远程计算机上的AD模块、Exchange功能命令在本地计算机执行
摘要:$RemoteServerDC = "dc01" $RemoteUserName = "xx\ssuser" $RemotePassword = 'password' $RemotePassword_sec = ConvertTo-SecureString $RemotePassword -AsPl 阅读全文
posted @ 2021-05-26 10:03 momingliu11 阅读(156) 评论(0) 推荐(0) 编辑
PowerShell执行当前目录下的脚本(无需启用允许脚本运行权限)
摘要:::PowerShell执行当前目录下的脚本(无需启用允许脚本运行权限)powershell.exe -executionpolicy bypass -noprofile -noninteractive -file "%~dp0\Xcopy.ps1" PowerShell执行当前目录下的脚本 阅读全文
posted @ 2021-03-25 17:39 momingliu11 阅读(202) 评论(0) 推荐(0) 编辑
PowerShell查询Windows事件日志
摘要:$xml=@"<QueryList> <Query Id="0" Path="Security"> <Select Path="Security">*[EventData[Data[@Name='ProcessName'] and (Data='c:\windows\system32\winlogo 阅读全文
posted @ 2021-03-17 15:09 momingliu11 阅读(317) 评论(0) 推荐(0) 编辑
AD用户添加到组
摘要:#将test OU下所有用户添加到组“品牌中心-读写” $users = Get-ADUser -Filter 'Enabled -eq "true" ' -SearchBase "OU=test,OU=da,DC=xx,DC=com" Add-ADGroupMember -Identity "品牌 阅读全文
posted @ 2021-02-20 14:05 momingliu11 阅读(272) 评论(0) 推荐(0) 编辑
Hyper-V自定义专用网络网段
摘要:Hyper-V默认的专用网络默认只能自动获取IP,如果需要使用自定义网段,比如192.168.0.0/24网段,则方法如下: # 创建名为internal的虚拟交换机 New-VMSwitch -SwitchName "internal" -SwitchType Internal # 查看 inte 阅读全文
posted @ 2020-12-15 10:06 momingliu11 阅读(1136) 评论(0) 推荐(0) 编辑

1 2 3 4 5 ··· 14 下一页