Skip to content

Instantly share code, notes, and snippets.

@devendrasv
Last active December 14, 2015 05:58
Show Gist options
  • Save devendrasv/6bfb2416864c7cacc937 to your computer and use it in GitHub Desktop.
Save devendrasv/6bfb2416864c7cacc937 to your computer and use it in GitHub Desktop.
#load assemblies and powershell snapin
[System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms")
Add-PSSnapin Microsoft.SharePoint.PowerShell
# end of loading assemblies
$form = new-object System.Windows.Forms.form
$form.Text = "Installed Apps in Host web"
#Textbox to enter Host web URL
$txtULSlogslevel = new-object System.Windows.Forms.TextBox
$txtULSlogslevel.Location = new-object System.Drawing.Size(20,19)
$txtULSlogslevel.Size = new-object System.Drawing.Size(150,23)
$form.Controls.Add($txtULSlogslevel)
#End of Textbox to enter Host web URL
#Button to execute the command to Get app details
$GetApps = new-object System.Windows.Forms.Button
$GetApps.Location = new-object System.Drawing.Size(170,19)
$GetApps.Size = new-object System.Drawing.Size(75,23)
$GetApps.Text = "Get Apps"
$GetApps.Add_Click({Populatetable})
$form.Controls.Add($GetApps)
# end of Button to execute the command to Get app details
#Data table to store App details
$GetAppsTable = New-Object System.Data.DataTable
$GetAppsTable.TableName = "GetApps"
$GetAppsTable.Columns.Add("Title");
$GetAppsTable.Columns.Add("Appwebfullurl");
#ENd of app details data table
#Datagrid control
$dgDataGrid_Apps = new-object System.windows.forms.DataGrid
$dgDataGrid_Apps.AllowSorting = $True
$dgDataGrid_Apps.Location = new-object System.Drawing.Size(50,50)
$dgDataGrid_Apps.size = new-object System.Drawing.Size(500,350)
$form.Controls.Add($dgDataGrid_Apps)
#end of datagrid control
# function to display the details in Grid
function Populatetable
{
$SiteUrl = $txtULSlogslevel.Text.ToString();
$Appdetails = Invoke-Expression "Get-SPAppInstance -Web $SiteUrl | select Title,Appwebfullurl"
foreach ($item in $Appdetails)
{
$GetAppsTable.Rows.Add($item.Title,$item.Appwebfullurl)
}
$dgDataGrid_Apps.DataSource = $GetAppsTable
}
#End of function
$form.topmost = $true
$form.Add_Shown({$form.Activate()})
$form.ShowDialog()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment