Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function PS-Session{ #Creates interactive Session
- Param(
- [Parameter(Mandatory=$true,
- HelpMessage="Enter the computer name you wish to connect too")]
- [string]$ComputerName,
- [Parameter(Mandatory=$true,
- HelpMessage = "Enter your credentials")]
- [string]$Credentials
- )
- New-PSSession -ComputerName $ComputerName -Credential $Credentials
- while($loop){
- Clear-Host
- [int]$loop = Read-Host "Input 0 to disconnect"
- }
- Get-PSSession -ComputerName -Credential | Disconnect-PSSession -Session
- }#End of Session
- Function Populate{
- Set-Location "C:\Users\$env:USERNAME\Documents"
- $Header =@"
- ===================================
- Header Header Header Header Header
- ===================================
- "@
- #Creating the 15 files
- for($i = 1; $i -ne 6; $i++){
- New-Item -Force "File$i.txt"
- New-Item -Force "File$i.DOCX"
- New-Item -Force "File$i.PS1"
- Write-Output "$Header" > File$i.TXT
- Write-Output "$Header" > File$i.DOCX
- Write-Output "$Header" > File$i.PS1
- $MyArr+= "Files$i.TXT"
- $MyArr+= "Files$i.DOCX "
- $MyArr+= "Files$i.PS1 "
- [array]$FileArray = $MyArr -Split(" ")
- }
- }#End of Populate
- Function TreeCheckandFill{ #Uses the files made in populate. Finds or creates the proper tree system for them and then copies them over.
- $Populate = Read-Host "Populate? [Y]es [N]o"
- if($Populate -eq "Y"){
- Populate
- }
- #Testing if Win213 Directory exists
- $DirectoryCheck = 0;
- if(Test-Path "Win213_Files" -PathType Container){
- $DirectoryCheck = 1;
- }
- Write-Host $DirectoryCheck
- if($DirectoryCheck -eq 0){
- New-Item -ItemType Directory "Win213_Files"
- New-Item -ItemType Directory -Path "Win213_Files\TXT"
- New-Item -ItemType Directory -Path "Win213_Files\DOCX"
- New-Item -ItemType Directory -Path "Win213_Files\PS1"
- }else{
- $Answer = Read-host "Tree exists do you wish to populate? [Y]es"
- if($Answer -eq "Y"){
- $Date = Get-Date -UFormat "%A %m/%d/%Y %R %Z"
- if(-not(Test-Path "C:\Users\$env:USERNAME\AppData\Local\Temp\Log.txt")){
- New-Item -Path "C:\Users\$env:USERNAME\AppData\Local\Temp\Log.txt"
- }
- for($i = 1; $i -lt 6; $i+= 1){
- Copy-Item "File$i.TXT" "Win213_Files\TXT"
- Write-Output "$Date, Created File$1.TXT" >> "C:\Users\$env:USERNAME\AppData\Local\Temp\Log.txt"
- Copy-Item "File$i.DOCX" "Win213_Files\DOCX"
- Write-Output "$Date, Created File$1.DOCX" >> "C:\Users\$env:USERNAME\AppData\Local\Temp\Log.txt"
- Copy-Item "File$i.PS1" "Win213_Files\PS1"
- Write-Output "$Date, Created File$1.PS1" >> "C:\Users\$env:USERNAME\AppData\Local\Temp\Log.txt"
- }
- }
- }
- }#End of Tree check and fill
- Function SysInv{
- Get-AdComputer
- $Test = Test-Connection "Computer" -Quiet -Count 1
- if ($test){
- "Online"
- }else{
- "Offline"
- }
- }#End of SysInv NOT COMPLETE
- Function Delete{ #Takes file input and finds+removes that file
- Set-Location "C:\Users\$env:USERNAME\Documents"
- [string]$Garbage = Read-Host("Input the files you wish to be deleted. #E.G *2.TXT, *3.DOCX")
- $MyArr = $Garbage -split(",")
- Get-ChildItem $Garbage -Recurse | Remove-Item #Searchs for inputed item in the Document Location
- if(Get-ChildItem $Garbage -Recurse){
- $Date = Get-Date -UFormat "%A %m/%d/%Y %R %Z"
- if(-not(Test-Path "C:\Users\$env:USERNAME\AppData\Local\Temp\Log.txt")){
- New-Item -Path "C:\Users\$env:USERNAME\AppData\Local\Temp\Log.txt"
- Write-Output "$Date, User deleted file $Garbage" >> "C:\Users\$env:USERNAME\AppData\Local\Temp\Log.txt"
- }
- }
- }#End of Delete
- Function Menu{
- $menu = @"
- ++++++++++++++++++++++
- `t`t`t Menu `t`t`t
- ++++++++++++++++++++++
- [1]Start PS-Session
- [2]Check Directory
- [3]System Inventory
- [4]Delete Files
- [5]Exit
- "@
- do{
- Clear-Host
- Write-host -BackgroundColor Black -ForegroundColor White $menu
- $input = Read-Host
- switch($input)
- {
- '1'{PS-Session;pause;break;}
- '2'{TreeCheckandFill;pause;break;}
- '3'{SysInv;pause;break;}
- '4'{Delete;pause;break;}
- }
- }while($input -ne "5")
- }#End of Menu
- Menu
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement