Skip to content

【开源自荐】PowerGPT - 无需懂PowerShell就可以在Windows命令行做任何事情 #2980

Open
@ouromoros

Description

@ouromoros

写PowerShell脚本需要一定的专业知识,有时也较为麻烦,但我们常常会有在Windows下用进行批量操作的需求。

PowerGPT是一个纯PowerShell编写的轻量工具,只需要打出PowerGPT <要执行的任务>就可以让AI帮你编写命令并执行。

安装十分简单,在PowerShell中运行:

Install-Module PowerGPT

首次运行时需要输入OpenAI API Key,在国内环境下时需要打开系统代理。

$ .\PowerGPT.ps1 "print first lines and last lines for each file in current folder"
The description is too vague, do you mean:
[0] For each file in current directory, print the first line and then print the last line of the file.
[1] For each file in current directory, print the first line of the file. After that, for each file, print the last line of the file.
Choose one description that matches your task: : 1
Will execute script:
-----
Get-ChildItem | ForEach-Object {
    $file = $_.FullName
    Write-Host "First line of $file:"
    Get-Content $file -TotalCount 1
}
Get-ChildItem | ForEach-Object {
    $file = $_.FullName
    Write-Host "Last line of $file:"
    Get-Content $file -Tail 1
}
-----
continue?([y]es, [n]o)
-----

Github: https://github.com/ouromoros/PowerGPT

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions