powershell

How do I configure a startup/config script for Powershell?

♀尐吖头ヾ 提交于 2021-01-04 14:54:05
问题 I am looking to define a set of custom aliases/variables for use every time I launch PowerShell. I am looking for the PowerShell alternative to the .bashrc file. I have tried putting a file named Profile.ps1 in the home directory, but it never runs. What do I need to do to get this file to run? I am using Windows 10. 回答1: I'd start by reading through Microsoft's documentation about_Profiles. I've linked to the 5.1 version of the documentation since that's likely what you have on Windows 10,

ForEach-Object OutString, Powershell Awk Equivalents

筅森魡賤 提交于 2021-01-04 13:03:51
问题 I'm a long time Bash enthusiast trying to get my bearings with Powershell. I'm trying to do something that could easily be accomplished with Awk, but I can't seem to find a solution in Powershell documentation. I'm essentially trying to select the third value from the output of the command delimited by / Get-ADOrganizationalUnit -Properties CanonicalName -Filter * | Select-Object -ExpandProperty CanonicalName | Select-String ".*/Example/.*" example.local/Example/ExampleOU1 example.local

MSSQL绕过微软杀毒提权案例

余生颓废 提交于 2021-01-04 08:32:37
声明: 该公众号大部分文章来自作者日常学习笔记,也有少部分文章是经过原作者授权和其他公众号白名单转载,未经授权,严禁转载,如需转载,联系开白。 请勿利用文章内的相关技术从事非法测试,如因此产生的一切不良后果与文章作者和本公众号无关。 所有话题标签: #Web安全 #漏洞复现 #工具使用 #权限提升 #权限维持 #防护绕过 #内网安全 #实战案例 #其他笔记 #资源分享 #MSF 0x01 前言 朋友发来的是一个支持外链的MSSQL, 未做站库分离处理, 且可以直接通过xp_cmdshell执行命令,但是由于目标系统为Windows 2019,自带的有微软的 Windows Defender防病毒,他在执行 PowerShell攻击命令 时被拦截后不知道要怎么绕过,所以让我帮着给看下。 0x02 信息搜集 目标机器基本信息: 目标系统: Windows Server 2019(10 .0 .17763 暂缺 Build 17763) 数据库版本: Microsoft SQL Server 2014 - 12 .0 .2000 .8 ( X64 ) 当前权限: nt service \ mssqlserver 开放端口:80、135、445、1433、2383( ssas )、3389...... 进程名称: Ssms .exe 、 sqlwriter .exe 、 sqlservr

Right usage of 2>&1 | tee or | tee with powershell

て烟熏妆下的殇ゞ 提交于 2021-01-04 07:43:51
问题 I want to see the output of the command in the console and save it in a file so I have these two options: When I use command | tee output.txt somehow it generates no output file at all but it works as usual in the console. When I use command 2>&1 | tee output.txt it generates a fine output file but the text in the console appears in red. Is there any way to either fix the first option or let the text appear as usual in the second one? I am using Windows PowerShell (Windows 10) and the

PowerShell list inherited methods with Get-Member

僤鯓⒐⒋嵵緔 提交于 2021-01-04 04:22:29
问题 I am exploring what pipeline functionality is also available as methods. For example... @('1', '2', '3', '2') | where {$_ -in @('2')} will return the two '2'. But I can also do... @('1', '2', '3', '2').Where({$_ -in @('2')}) and get the same result. I also want to Group , and while @('1', '2', '3', '2') | group {$_.Count -gt 1} doesn't do the actual grouping I want, it does... something. But @('1', '2', '3', '2').Group({$_.Count -gt 1}) fails with Method invocation failed because [System

PowerShell list inherited methods with Get-Member

寵の児 提交于 2021-01-04 04:20:46
问题 I am exploring what pipeline functionality is also available as methods. For example... @('1', '2', '3', '2') | where {$_ -in @('2')} will return the two '2'. But I can also do... @('1', '2', '3', '2').Where({$_ -in @('2')}) and get the same result. I also want to Group , and while @('1', '2', '3', '2') | group {$_.Count -gt 1} doesn't do the actual grouping I want, it does... something. But @('1', '2', '3', '2').Group({$_.Count -gt 1}) fails with Method invocation failed because [System

PowerShell list inherited methods with Get-Member

北城余情 提交于 2021-01-04 04:15:30
问题 I am exploring what pipeline functionality is also available as methods. For example... @('1', '2', '3', '2') | where {$_ -in @('2')} will return the two '2'. But I can also do... @('1', '2', '3', '2').Where({$_ -in @('2')}) and get the same result. I also want to Group , and while @('1', '2', '3', '2') | group {$_.Count -gt 1} doesn't do the actual grouping I want, it does... something. But @('1', '2', '3', '2').Group({$_.Count -gt 1}) fails with Method invocation failed because [System

Powershell call cmd.exe command like copy /b

与世无争的帅哥 提交于 2021-01-04 02:06:35
问题 I saw this already Fast and simple binary concatenate files in Powershell I'm not interested by the answer above I'm interested about what's wrong with syntax below : when I call a cmd.exe command like copy /b : function join-file { copy /b $($args[0])+$($args[1]) $($args[2]) } I get an error Copy-Item : A positional parameter cannot be found 回答1: As the error alludes to, copy is actually just an alias for Copy-Item and it does not have a /b parameter. You can call cmd to use its copy command

Powershell call cmd.exe command like copy /b

∥☆過路亽.° 提交于 2021-01-04 01:53:22
问题 I saw this already Fast and simple binary concatenate files in Powershell I'm not interested by the answer above I'm interested about what's wrong with syntax below : when I call a cmd.exe command like copy /b : function join-file { copy /b $($args[0])+$($args[1]) $($args[2]) } I get an error Copy-Item : A positional parameter cannot be found 回答1: As the error alludes to, copy is actually just an alias for Copy-Item and it does not have a /b parameter. You can call cmd to use its copy command

Powershell call cmd.exe command like copy /b

女生的网名这么多〃 提交于 2021-01-04 01:49:08
问题 I saw this already Fast and simple binary concatenate files in Powershell I'm not interested by the answer above I'm interested about what's wrong with syntax below : when I call a cmd.exe command like copy /b : function join-file { copy /b $($args[0])+$($args[1]) $($args[2]) } I get an error Copy-Item : A positional parameter cannot be found 回答1: As the error alludes to, copy is actually just an alias for Copy-Item and it does not have a /b parameter. You can call cmd to use its copy command