SharePoint Commands Run itself bu Not with Powershell Studio

Hello

I have problem about script with runs on Sharepoint environment. When i just run the cmdlet itself, (merge-splogfile) creating a file and its visible on desktop. When i run whole script, process is stucking at about %90 percent and not completing itself.

Other buttons are working fine
$path and $correlation values are okay but script is not finishing.

Any idea?

[pre]

#------------------------------------------------------------------------

Source File Information (DO NOT MODIFY)

Source ID: ab521cf7-fea6-458f-b669-ac5e6810fcdd

Source File: correlation.psf

#------------------------------------------------------------------------
#region File Recovery Data (DO NOT MODIFY)
<#RecoveryData:
hgMAAB+LCAAAAAAABABlk0mLo1AUhfdC/kNRW6HVF6dAuuA5JdFEjXOyM87D0zhW9Nd3qN409F0d
LucsDodvbyVROyf9IoVj+PEWQ9E2vz+3v6jPrw328bE3+iIrmrBWijrRQ5R8RW3fJ3U4vn2/nkO6
J/5z/OSUtkdfGqmU1Kz3F0hDKBqSCP+eACWv9nYmWKH7ivmGc0Y6bblQlbeOh9ry6mW1LhSneBZP
/BQZs/QEjJM9QJgeN1hkPV2qkiNZ0XpbOQyNMa6cOTnmA5xSUi54XFpV2ka7q6RGGbnOYr6KXjPn
vegSfM1FC7vgCOQEAZYNRkr+qTlCwG+fYOdl7VnLBuHyfVMUVaZkLbDcl8pnW031eAHxfuk61iXv
6fUQ5Fm5RLfBzp21JLwUMocNtjgg7zzIHo8nJIQRQ5WKR8qzQC1CNdkVrRVWqgoHRWZOQkee2s7n
8/sqjfpOA2RjJDDj0NIhSu2u8gZDynKd2R4eg8GPGtCMScElkw7PLOVN9PXo+64FQo5kAVHP8SHm
7TJej/UjdQkOR3z58IkmsuX6/iKSd1OlfLzHsLcuSdNkVdUOaeSZQb3SO31fdgmYbL25HXCuO5bO
slYoKQI3WDW3KWHmJwWFSNIhLmXOCM0GC7mgQ7L67h1ojiCAnDZq7SIMBZps5aXEi3oWo7s9XCuW
Sc41flhSJX6orNgsfU7wGRXid1CbItPa1gYjTHqHJFT2z9JrRuoWbVPzGce3C3UOLPr+RGdK7F1m
l52XOOMKacTPSMshUof0pKNtSFoZoF71I5TKboMJ6thL6mzwU3C96cZTYkSqgoPgnfU1mVWfyVdz
iCXIiFyYT+x9TGv1Tkwx7Rhstnp84JijcjPN75zPNlix1cXW6ggGL3vnoJR4J0OQg8mfLnTCe0nF
Dd7EUgLPVMeSoL2dzn9LGYR74geCHxzgMCToURfJ8EG8P3viX+6+/gAwTzSUhgMAAA==#>
#endregion

<#
.NOTES

Code generated by: SAPIEN Technologies, Inc., PowerShell Studio 2018 v5.5.152
Generated on: 1/24/2020 11:04 PM
Generated by: Umut

.DESCRIPTION
GUI script generated by PowerShell Studio 2018
#>

#----------------------------------------------
#region Application Functions
#----------------------------------------------

#endregion Application Functions

#----------------------------------------------

Generated Form Function

#----------------------------------------------
function Show-correlation_psf {

#----------------------------------------------
#region Import the Assemblies
#----------------------------------------------
[void][reflection.assembly]::Load(‘System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’)
[void][reflection.assembly]::Load(‘System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’)
#endregion Import Assemblies

#----------------------------------------------
#region Generated Form Objects
#----------------------------------------------
[System.Windows.Forms.Application]::EnableVisualStyles()
$form1 = New-Object ‘System.Windows.Forms.Form’
$button1 = New-Object ‘System.Windows.Forms.Button’
$buttonFinish = New-Object ‘System.Windows.Forms.Button’
$buttonMerge = New-Object ‘System.Windows.Forms.Button’
$buttonCorrelationID = New-Object ‘System.Windows.Forms.Button’
$buttonFilename = New-Object ‘System.Windows.Forms.Button’
$InitialFormWindowState = New-Object ‘System.Windows.Forms.FormWindowState’
#endregion Generated Form Objects

#----------------------------------------------

User Generated Script

#----------------------------------------------

$form1_Load={
#TODO: Initialize Form Controls here

}

$buttonFilename_Click={
$path = [void][Reflection.Assembly]::LoadWithPartialName(‘Microsoft.VisualBasic’)

$title = ‘Path’
$msg = ‘Enter the File Name:’

$text = [Microsoft.VisualBasic.Interaction]::InputBox($msg, $title)

}

$buttonCorrelationID_Click={
#TODO: Place custom script here
$path2 = [void][Reflection.Assembly]::LoadWithPartialName(‘Microsoft.VisualBasic’)

$title2 = ‘Correlation’
$msg2 = ‘Enter the CorrelationID:’

$text2 = [Microsoft.VisualBasic.Interaction]::InputBox($msg2, $title2)
}

$buttonMerge_Click={
#TODO: Place custom script here
$result= Merge-SpLogFile -path C:\Users$env:USERNAME\Desktop$text.txt -Correlation $text2
}

$buttonFinish_Click={
#TODO: Place custom script here

}

$button1_Click={
#TODO: Place custom script here
Invoke-Item -path C:\Users$env:USERNAME\Desktop$text.txt
}

–End User Generated Script–

#----------------------------------------------
#region Generated Events
#----------------------------------------------

$Form_StateCorrection_Load=
{
#Correct the initial state of the form to prevent the .Net maximized form issue
$form1.WindowState = $InitialFormWindowState
}

$Form_Cleanup_FormClosed=
{
#Remove all event handlers from the controls
try
{
$button1.remove_Click($button1_Click)
$buttonFinish.remove_Click($buttonFinish_Click)
$buttonMerge.remove_Click($buttonMerge_Click)
$buttonCorrelationID.remove_Click($buttonCorrelationID_Click)
$buttonFilename.remove_Click($buttonFilename_Click)
$form1.remove_Load($form1_Load)
$form1.remove_Load($Form_StateCorrection_Load)
$form1.remove_FormClosed($Form_Cleanup_FormClosed)
}
catch { Out-Null <# Prevent PSScriptAnalyzer warning #> }
}
#endregion Generated Events

#----------------------------------------------
#region Generated Form Code
#----------------------------------------------
$form1.SuspendLayout()

form1

$form1.Controls.Add($button1)
$form1.Controls.Add($buttonFinish)
$form1.Controls.Add($buttonMerge)
$form1.Controls.Add($buttonCorrelationID)
$form1.Controls.Add($buttonFilename)
$form1.AutoScaleDimensions = ‘6, 13’
$form1.AutoScaleMode = ‘Font’
$form1.ClientSize = ‘284, 261’
$form1.Name = ‘form1’
$form1.Text = ‘Form’
$form1.add_Load($form1_Load)

button1

$button1.Location = ‘53, 208’
$button1.Name = ‘button1’
$button1.Size = ‘169, 41’
$button1.TabIndex = 4
$button1.Text = ‘button1’
$button1.UseCompatibleTextRendering = $True
$button1.UseVisualStyleBackColor = $True
$button1.add_Click($button1_Click)

buttonFinish

$buttonFinish.Location = ‘53, 178’
$buttonFinish.Name = ‘buttonFinish’
$buttonFinish.Size = ‘169, 23’
$buttonFinish.TabIndex = 3
$buttonFinish.Text = ‘Finish’
$buttonFinish.UseCompatibleTextRendering = $True
$buttonFinish.UseVisualStyleBackColor = $True
$buttonFinish.add_Click($buttonFinish_Click)

buttonMerge

$buttonMerge.Location = ‘29, 94’
$buttonMerge.Name = ‘buttonMerge’
$buttonMerge.Size = ‘218, 57’
$buttonMerge.TabIndex = 2
$buttonMerge.Text = ‘Merge!’
$buttonMerge.UseCompatibleTextRendering = $True
$buttonMerge.UseVisualStyleBackColor = $True
$buttonMerge.add_Click($buttonMerge_Click)

buttonCorrelationID

$buttonCorrelationID.Location = ‘141, 31’
$buttonCorrelationID.Name = ‘buttonCorrelationID’
$buttonCorrelationID.Size = ‘106, 57’
$buttonCorrelationID.TabIndex = 1
$buttonCorrelationID.Text = ‘CorrelationID’
$buttonCorrelationID.UseCompatibleTextRendering = $True
$buttonCorrelationID.UseVisualStyleBackColor = $True
$buttonCorrelationID.add_Click($buttonCorrelationID_Click)

buttonFilename

$buttonFilename.Location = ‘29, 31’
$buttonFilename.Name = ‘buttonFilename’
$buttonFilename.Size = ‘106, 57’
$buttonFilename.TabIndex = 0
$buttonFilename.Text = ‘Filename’
$buttonFilename.UseCompatibleTextRendering = $True
$buttonFilename.UseVisualStyleBackColor = $True
$buttonFilename.add_Click($buttonFilename_Click)
$form1.ResumeLayout()
#endregion Generated Form Code

#----------------------------------------------

#Save the initial state of the form
$InitialFormWindowState = $form1.WindowState
#Init the OnLoad event to correct the initial state of the form
$form1.add_Load($Form_StateCorrection_Load)
#Clean up the control events
$form1.add_FormClosed($Form_Cleanup_FormClosed)
#Show the Form
return $form1.ShowDialog()

} #End Function

#Call the form
Show-correlation_psf | Out-Null

[/pre]

upp