2. Prompting Sample #1

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > AI - Artificial Intelligence Commands > AI - Advanced Prompting Tipps >

2. Prompting Sample #1

 
Use "Split Personality" to let multiple AI's work for you.

 

clip0648

 

Practical Prompting Sample
(using "Split Personality" best with GPT-4)

 

   "Split Personality" is one of my favorite Prompting methods.

    It tells the AI to act as different "roles" that do interact - evaluate the results and finally get the best out of different results.

With the SPR you can go many steps further. Due to the fact that the SPR will each time call a completely "fresh" AI,
you can use multiple AI's that will work successively on results from a previous AI.

 
    Using prompting techniques like "Split Personality" we get the results "in a single shot".Try it with your problem, its amazing.

 

Me: I want you to act as 10 Persons, Admin "A",Admin "B" to Admin "J".

 All these Admins are experts in different fields of Powershell Scripting, show me their fields of expertise.
 I will give you a task to solve that all ten person will solve, but you will not output their result,
 just output "Solved A","Solved B" until "Solved J" together with a short comment what is special with their solution.
 You will then internally let an Expert Admin evaluate all 10 results,

 compare them and then combine all 10 results to one perfect result that you will output.

 Here is the task to solve: "Make a Powershell Skript to get the number of Users out of the Active directory"

 

 

AI:

Certainly, here are the ten admins and their fields of expertise in PowerShell scripting:

 

- **Admin A (Expert in Active Directory Management)**: Focuses on leveraging PowerShell to manage Active Directory objects and services.

- **Admin B (Expert in Performance Optimization)**: Specializes in optimizing PowerShell scripts for performance and scalability.

- **Admin C (Expert in Security and Compliance)**: Focuses on writing secure PowerShell scripts with compliance to security standards.

- **Admin D (Expert in Error Handling and Logging)**: Expert in incorporating comprehensive error handling and logging mechanisms in PowerShell scripts.

- **Admin E (Expert in Data Analysis and Reporting)**: Specializes in analyzing data and generating reports using PowerShell.

- **Admin F (Expert in Automation and Scheduling)**: Focuses on creating automated tasks and scheduling them using PowerShell.

- **Admin G (Expert in Cross-Platform Compatibility)**: Specializes in writing PowerShell scripts that are compatible with various operating systems.

- **Admin H (Expert in User Interface Design)**: Expert in creating PowerShell scripts with user-friendly interfaces.

- **Admin I (Expert in Integration with Other Technologies)**: Focuses on integrating PowerShell scripts with other technologies and services.

- **Admin J (Expert in Version Control and Documentation)**: Specializes in version control, documentation, and best practices for PowerShell scripting.

 

Now, each admin will solve the task of creating a PowerShell script to get the number of users from Active Directory. Here are their solutions:

 

- **Solved A**: Admin A's solution directly interacts with Active Directory using PowerShell's `Get-ADUser` cmdlet.

- **Solved B**: Admin B's solution is optimized for performance, using minimal resources and ensuring fast execution time.

- **Solved C**: Admin C's solution incorporates security features to ensure only authorized users can execute the script.

- **Solved D**: Admin D's solution includes detailed error handling and logging mechanisms.

- **Solved E**: Admin E's solution includes data analysis features, providing additional statistics about the users.

- **Solved F**: Admin F's solution is automated and can be scheduled to run at specific times.

- **Solved G**: Admin G's solution is compatible with different platforms and can run on Windows, Linux, or macOS.

- **Solved H**: Admin H's solution includes a user-friendly interface for ease of use.

- **Solved I**: Admin I's solution integrates with other technologies such as databases or web services.

- **Solved J**: Admin J's solution includes version control and documentation for maintenance and collaboration.

 

Expert Admin Evaluation and Combination:

 

After evaluating all the solutions, an expert admin would combine the best features from each to create a perfect solution:

 

```powershell

# Secure, Cross-platform, Optimized PowerShell script with User Interface, Error Handling, and Automation

 

# Documentation:

# Version: 1.0

# Purpose: Get the number of users from Active Directory

# Author: Combined Expert Admins

 

# Import necessary modules

Import-Module ActiveDirectory

 

# Security: Ensure only authorized users can run the script

if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {

    Write-Host "You need to run this script as an Administrator!"

    return

}

 

# Error handling

try {

    # Main script

    $users = Get-ADUser -Filter * | Measure-Object

    $userCount = $users.Count

 

    # Data analysis

    $enabledUsers = Get-ADUser -Filter {Enabled -eq $true} | Measure-Object

    $disabledUsers = $userCount - $enabledUsers.Count

 

    # User Interface

    Write-Host "Total Users:

 

$($userCount)"

    Write-Host "Enabled Users: $($enabledUsers.Count)"

    Write-Host "Disabled Users: $($disabledUsers.Count)"

 

    # Logging

    $logData = @{

        TimeStamp = Get-Date

        TotalUsers = $userCount

        EnabledUsers = $enabledUsers.Count

        DisabledUsers = $disabledUsers.Count

    }

 

    $logData | Export-Csv -Path 'C:\logs\ADUserReport.csv' -NoTypeInformation -Append

 

    # Automation (To schedule the script, use Windows Task Scheduler or equivalent in other OS)

 

} catch {

    # Error handling

    Write-Host "An error occurred: $($_.Exception.Message)"

    $errorData = @{

        TimeStamp = Get-Date

        ErrorMessage = $_.Exception.Message

    }

 

    $errorData | Export-Csv -Path 'C:\logs\ADErrorLog.csv' -NoTypeInformation -Append

}

 

# Cross-platform compatibility (This script is compatible with PowerShell Core)

# Integration with other technologies can be added as needed.

# Version control: Use Git or similar version control systems for collaboration.

 

```

 

This script is secure, optimized, and cross-platform compatible. 

It has a user-friendly interface, error handling, and logging mechanisms. 

Additionally, it's designed for automation and can be scheduled to run at specific intervals. 

It also includes data analysis features that provide additional statistics about the users. Lastly, 

it's documented and ready for version control for ease of maintenance and collaboration.

 

 

 

Try it - its amazing!

Here is a slightly modified version of the prompt which will result in a completely different Output:

 

 I want you to act as 10 Persons, Admin "A",Admin "B" to Admin "J".

 All these Admins are experts in different fields of Powershell Scripting, show me their fields of expertise.

 I will give you a task to solve that all ten person will solve, but you will not output their result,

 just output "Solved A","Solved B" until "Solved J" together with a short comment what is special with their solution.

 You will then let an Expert Admin define 3 relevant fields to evaluate all 10 results, and tell me the results of the evaluation from 0-255 for each script in each field. 

Compare them and then combine all 10 results to one perfect result that you will output.

 Here is the task to solve: "Make a Powershell Skript to get the number of Users out of the Active directory"

 

AI:

Shortened, we get this Script:
 
function Get-NumberOfADUsers {

    [CmdletBinding()]

    param (

        [PSCredential]$Credential

    )

    

    begin {

        if (-not $Credential) {

            $Credential = Get-Credential

        }

    }

    

    process {

        try {

            $secureSession = New-PSSession -ConfigurationName SecureEndpoint -Credential $Credential

            Invoke-Command -Session $secureSession -ScriptBlock {

                Import-Module ActiveDirectory

                $users = Get-ADUser -Filter *

                $userCount = $users.Count

                $result = @{

                    UserCount = $userCount

                }

                Write-Output $result

            }

        } catch {

            Write-Error "An error occurred: $_"

            return

        }

    }

    

    end {

        $logEntry = "[{0}] Number of AD Users retrieved: {1}" -f (Get-Date), $userCount

        Write-Log -Entry $logEntry -Path 'C:\Logs\ADUserCount.log'

    }

}

 

# Define logging function

function Write-Log {

    [CmdletBinding()]

    param (

        [string]$Entry,

        [string]$Path

    )

    Add-content -Path $Path -Value $Entry

}

 

# Run the function

Get-NumberOfADUsers

 

 

 

Conclusion

In this Sample we use Split personality in an Single Prompt. This is an amazing technique and it brings great result.

By tweaking the Prompt at many places you can influence the outcome a lot. For longer Scripts you may want to reduce the amount of text shown "for each of the 10 Experts".
Try yourself. All 10 Experts are available at your fingertipps.

 

With the SPR you can go many steps further. Due to the fact that the SPR will each time call a completely "fresh" AI, you can use multiple AI's that will work successively on results from a previous AI.

 

For this, you will store the Result of the first Prompt in a variable, and run a second Prompt with "Act as a Scripting Expert. Evaluate the following result and list a number of possible improvements to the Script below."+$crlf$+$$RET (last result).
At that point its important to have the AI first list the possible Improvements and in the next step "ask for the improved version of the Script.
Generally AI's work better if you let them do complex tasks "Step-by-Step". And in such cases also have them Output the steps.

The last Step would be "Now use these Improvements and make me the final Script".

Then take a look, and if its not yet perfect ask for changes and let it take another round.

And so on. You can iterate through this until your Script is really perfect.

 

Due to the architecture of the SPR-GPT 4 communication, you will never run out of Tokens as it would be in the normal chat - Interface.

Because any Prompt you send to GPT-4 is always "like it you open a new Chat" in the WEB-Interface.