event receiver sharepoint online - events

I have a basic question regarding SharePoint Online.
A list was made in the past. On this list a custom event receiver was attached.
I need to detach the event receiver from the list but I do not know where I can find an overview of all event receivers attached to objects in SharePoint.
This seems to be very basic, but I have searched the web and I can only find how to create and attach, but not how to detach and overview.
Thank you!

I've never done this myself but I believe that you need to install the SharePoint online tools.
You will then need to do then do some powershell commands to then remove.
# Paths to SDK. Please verify location on your computer.
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
# Insert the credentials and the name of the admin site
$Username="admin#tenant.onmicrosoft.com"
$AdminPassword=Read-Host -Prompt "Password" -AsSecureString
$Url="https://tenant.sharepoint.com/sites/teamsitewithlibraries"
$ListTitle="kriiv"
$EventReceiverGUID="154d2ca2-8335-464c-9059-214cdcc1c2c1"
Get-SPOListEventreceivers -Username $Username -AdminPassword $AdminPassword -Url $Url -ListTitle $ListTitle -EventReceiverGUID $EventreceiverGUID
I've taken the above code from this
Hope this helps
Truez

try the pnp powershell, quite handy.
https://github.com/OfficeDev/PnP-PowerShell/blob/master/Documentation/RemoveSPOEventReceiver.md

Related

PS script to copy data to external file share location

Scenario:
Site to Site VPN is configured with my network and with a remote Data centre and there is no AD Trust
On a daily basis, I need to copy the data from my server folder to remote file share location
For example:
Platform: Windows 2008
Server folder : D:\Data
Remote file share location: \1.2.3.4\Data
For remote file share location, they have different domain (for example username: xyz\user1)
How can I have a script where the data generated in our server folder (D:\Data) can be replicated to remote file share location using their credentials on a daily basis?
I'm confused with the step where how I can pass the 3rd party credentials to copy the data to their location as AD Trust is not configured.
Thanks in Advance.
You can use something like $cred = Get-Credential to create a variable that will store the credential in a PSCredential object.
Then when you call on it later you can just use $cred instead of signing in.
This will cause the script to prompt for domain credentials each time the script is run, and then use those when moving the files. I have used a simple cmdlet below and separated out the credential variable for readability.
Get-CimInstance Win32_DiskDrive -ComputerName Server01 -Credential $cred

Cannot import pfx key file - Visual studio 2019

I have a VSTO add-in which I'm migrating from VS2010 to visual studio 2019. However, I forgot the password to mypfx key attached to the main project of the solution.
I'm now trying to create a new one and import it into my project to replace the old key which I can't use anymore. I've tried subsequent steps indicated on stackoverflow and other sites, but I keep getting the following build error in VS2019:
Cannot import the following key file: newtest.pfx. The key file may be password protected.
To correct this, try to import the certificate again or manually install the certificate to the Strong Name CSP with the following key container name: VS_KEY_10580C0D68F0E891 <project name>
However, that's exactly what I'm trying. First, I create a new certificate as indicated here:
New-SelfSignedCertificate -DnsName "somename" -CertStoreLocation "cert:\LocalMachine\My"
Then I export it :
$CertPassword = ConvertTo-SecureString -String “somepass” -Force –AsPlainText
Export-PfxCertificate -Cert cert:\LocalMachine\My\<somethumbprint> -FilePath <path>/newtest.pfx -Password $CertPassword
Final step, as in this question is to use sn.exe with the following command:
sn -i sg newtest.pfx VS_KEY_XXXXXXXXXXXX
The command runs successfully, but when I restart vs2019 again and open the add-in solution, the samen error pops up again. What can I do?
EDIT
Also, I cannot uncheck the "sign clickonce manifest" checkbox in Project > Properties > Signing. THis means that the Select from store option as mentioned in the answer below is unavailable.
I have moved this project to another computer, could that be the cause?
A bit stuck here.
I had the exact same problem a few weeks ago. What helped in my case is that I created the certificate just like you (placed in the Personal Certificate Store), then instead of the command line tools I used the Signing menu in Visual Studio 2019 to import the cert.
Right Click on the Project, then Properties, then Signing. Enable Sign the ClickOnce manifest and Select from Store to use the newly created certificate.

Why does signtool.exe only find certificate when run as admin?

I'm setting up a new development laptop, and have installed a self-issued code signing certificate. I can see it in certmgr under my Current Users's Personal Certificates.
When I try to build from the Developer Command Prompt For Visual Studio 2017 I get:
error : SignTool Error: No certificates were found that met all the given criteria.
This always worked fine on my old laptop.
I have found if I run the same build from the command prompt after starting it as admin that signtool succeeds and can find the cert.
This has happened to 3/4 colleagues when we've set up new laptops. One guy is ok and can sign without running as admin. On our old laptops we never had to run as admin.
I've tried googling to find what could be the cause because I wasn't aware that running as admin or not should have any affect over this. I haven't found any reference to this problem.
How can we use signtool.exe without running it as admin?
When not running as admin it appears to be at the Private Key filter step where the cert I'm expecting to be selected gets filtered out:
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.9.12
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
C:\>signtool sign /v /debug /ph /i "<issuedby>" /fd sha256 /td sha256 "C:\TestSign.dll"
The following certificates were considered:
Issued to: Scott Langham
Issued by: <issuedby>
Expires: Sun Sep 25 09:54:55 2022
SHA1 hash: <a_hash>
Issued to: Scott Langham
Issued by: <issuedby_somethingelse>
Expires: Wed May 13 15:51:14 2020
SHA1 hash: <b_hash>
After EKU filter, 1 certs were left.
After expiry filter, 1 certs were left.
After Issuer Name filter, 1 certs were left.
After Private Key filter, 0 certs were left.
SignTool Error: No certificates were found that met all the given criteria.
I've ensured the version of signtool.exe I'm using is the same as the one that my colleague who has this working is using (10.0.18362.1). I've been able to spot any other differences between our systems.
I ran into this today and here is how I am now able to run signtool.exe via command line without elevating to admin.
Run 'mmc' and add the 'Certificates' snap-in
Select the correct key store location
(mine is in Local Computer so I select 'Computer account' here)
Find and select the certificate
Right click on the certificate, select All Tasks > Manage Private Keys...
In the 'Permissions for private keys' dialog, Add your user account and then give yourself 'Full Control'. You will now be able to sign using a normal command prompt.
Note: If you use a build machine, do the above steps for the account that performs the builds.
Similar to what #Baget said, I'd compare the certificates on your machine to that of your colleague who can successfully run the SignTool.exe command without the elevation token. Here's a chunk of PowerShell to assist you:
get-childitem -Path Cert:\ | foreach-object ({
$location = $_.Location
foreach($store in $_.StoreNames.Keys) {
get-childitem -Path "Cert:\$location\$store" | foreach-object ({
$thumb = $($_.ThumbPrint)
$issuer = $($_.Issuer)
if ($issuer -eq "CN=EXAMPLE, DC=EXAMPLE, DC=EXAMPLE, DC=EXAMPLE") {
write-host "$location $store $issuer"
}
})
}
})
Bear in mind that the output of the above may differ slightly if you run as a normal user and 'run as admin'.
Finally, do you and your colleague have the same UAC settings?
I found myself in a similar situation with signtool, it refused to work with an admin user but does work as actual Administrator.
In my case, I am not actually importing the certificate into the certificate store, but using a .pkcs12 file exported from a comodo certificate in firefox, so this makes things even stranger, as no permissions on any keys in the store are involved.
I tried granting myself permissions on some server key, but that did nothing.
I hope someone finds a solution to this problem.
In the meantime, I am signing my exe with osslsigncode instead, which works perfectly.
I extracted the exe and dependent dlls from the msys2 mingw64 build, here is a zip of everything in case it is of use to anyone, just extract it to a directory and put it in your PATH.
http://cachemiss.com/files/osslsigncode.zip
To extract this program yourself from an msys2 installation, you can use this command:
pacman --noconfirm -S mingw-w64-x86_64-osslsigncode
cd /mingw64/bin
mkdir ~/osslsigncode
cp osslsigncode.exe $(ldd osslsigncode.exe | sed -n 's,^.*\(/mingw64/[^ ]*\).*,\1,p' | sort -u) ~/osslsigncode/
cd
zip -9r osslsigncode.zip osslsigncode
I am using this in Visual Studio cmake builds with no issue.
There are two Certificate Store in Windows, User Store, and a machine store, you probably installed the certificate to the local machine, or you installed it when you run as elevated user.
Firstly you are getting such an error and you are using visual studio then See the signing tab in project properties. You will see a previously assigned signature (strong assembly)
If you enter the correct password here:
If your environment is the same as the environment in which the project is written, you will skip this error. Look the post on about the error
The reasons behind this error are:
1- Visual Studio needs some features when using certificate file to sign strong assembly.
ClickOnce Manifest Signing and Strong-Name Assembly Signing Using Visual Studio Project Designer's Signing Page
You can try this code to determine
signtool sign /debug /f mypfxfile.pfx /p <password> (mydllexectuable).exe
2- These settings can vary from machine to machine, and windows does not write these settings to the environment setting by default. check the config path
This part is just a deep note! not interested with the question you should add your private keystore file to request header and those all for this. My favorite steps about the creation of a certificate on this post

Problems with SQL Server 2012 on a Windows 2008 R2 Core Server

Created a script that installs an empty server to a server that uses an SQL Db, IIS, WebDeploy and FTP. Everything installs but when i try to run my createsqldatabaseb.ps1 it gives an error. Been searching a solution for about two weeks by now.
I've included a screenshot, ConfigurationFile.ini that setup.exe uses(SQL Server installer) and my script.
I'm looking for a small configuration error that prevents me from creating the Database.
Thanks.
Error that command gives
A couple of dism action to enable powershell etc...
dism /online /enable-feature /featurename:NetFx2-ServerCore
dism /online /enable-feature /featurename:NetFx3-ServerCore
dism /online /enable-feature /featurename:NetFx2-ServerCore-WOW64
dism /online /enable-feature /featurename:NetFx3-ServerCore-WOW64
dism /online /enable-feature /featurename:MicrosoftWindowsPowerShell
dism /online /enable-feature /featurename:MicrosoftWindowsPowerShell-WOW64
dism /online /enable-feature /featurename:ServerManager-PSH-Cmdlets
powershell Set-ExecutionPolicy Unrestricted
powershell ./InstallIIS.ps1
CnfigurationFile.ini
;SQL Server 2012 Configuration File
[OPTIONS]
; Specifies a Setup work flow, like INSTALL, UNINSTALL, or UPGRADE. This is a required parameter.
ACTION="Install"
; Detailed help for command line argument ENU has not been defined yet.
ENU="True"
; Setup will not display any user interface.
QUIET="False"
IACCEPTSQLSERVERLICENSETERMS="True"
; Setup will display progress only, without any user interaction.
QUIETSIMPLE="True"
; Specify whether SQL Server Setup should discover and include product updates. The valid values are True and False or 1 and 0. By default SQL Server Setup will include updates that are found.
UpdateEnabled="True"
; Specifies features to install, uninstall, or upgrade. The list of top-level features include SQL, AS, RS, IS, MDS, and Tools. The SQL feature will install the Database Engine, Replication, Full-Text, and Data Quality Services (DQS) server. The Tools feature will install Management Tools, Books online components, SQL Server Data Tools, and other shared components.
FEATURES=SQLENGINE,CONN,FULLTEXT
; Specify the location where SQL Server Setup will obtain product updates. The valid values are "MU" to search Microsoft Update, a valid folder path, a relative path such as .\MyUpdates or a UNC share. By default SQL Server Setup will search Microsoft Update or a Windows Update service through the Window Server Update Services.
UpdateSource="MU"
; Displays the command line parameters usage
HELP="False"
; Specifies that the detailed Setup log should be piped to the console.
INDICATEPROGRESS="False"
; Specifies that Setup should install into WOW64. This command line argument is not supported on an IA64 or a 32-bit system.
X86="False"
; Specify the root installation directory for shared components. This directory remains unchanged after shared components are already installed.
INSTALLSHAREDDIR="C:\Program Files\Microsoft SQL Server"
; Specify the root installation directory for the WOW64 shared components. This directory remains unchanged after WOW64 shared components are already installed.
INSTALLSHAREDWOWDIR="C:\Program Files (x86)\Microsoft SQL Server"
; Specify a default or named instance. MSSQLSERVER is the default instance for non-Express editions and SQLExpress for Express editions. This parameter is required when installing the SQL Server Database Engine (SQL), Analysis Services (AS), or Reporting Services (RS).
INSTANCENAME="MSSQLSERVER"
; Specify that SQL Server feature usage data can be collected and sent to Microsoft. Specify 1 or True to enable and 0 or False to disable this feature.
SQMREPORTING="False"
; Specify the Instance ID for the SQL Server features you have specified. SQL Server directory structure, registry structure, and service names will incorporate the instance ID of the SQL Server instance.
INSTANCEID="MSSQLSERVER"
; Specify if errors can be reported to Microsoft to improve future SQL Server releases. Specify 1 or True to enable and 0 or False to disable this feature.
ERRORREPORTING="False"
; Specify the installation directory.
INSTANCEDIR="C:\Program Files\Microsoft SQL Server"
; Agent account name
AGTSVCACCOUNT="NT Service\SQLSERVERAGENT"
; Auto-start service after installation.
AGTSVCSTARTUPTYPE="Automatic"
; CM brick TCP communication port
COMMFABRICPORT="0"
; How matrix will use private networks
COMMFABRICNETWORKLEVEL="0"
; How inter brick communication will be protected
COMMFABRICENCRYPTION="0"
; TCP port used by the CM brick
MATRIXCMBRICKCOMMPORT="0"
; Startup type for the SQL Server service.
SQLSVCSTARTUPTYPE="Automatic"
; Level to enable FILESTREAM feature at (0, 1, 2 or 3).
FILESTREAMLEVEL="0"
; Set to "1" to enable RANU for SQL Server Express.
ENABLERANU="False"
; Specifies a Windows collation or an SQL collation to use for the Database Engine.
SQLCOLLATION="Latin1_General_CI_AS"
; Account for SQL Server service: Domain\User or system account.
SQLSVCACCOUNT="NT Service\MSSQLSERVER"
; Windows account(s) to provision as SQL Server system administrators.
SQLSYSADMINACCOUNTS=".\Administrator"
; The default is Windows Authentication. Use "SQL" for Mixed Mode Authentication.
SECURITYMODE="SQL"
SAPWD="Opleelan8"
; Provision current user as a Database Engine system administrator for SQL Server 2012 Express.
ADDCURRENTUSERASSQLADMIN="False"
; Specify 0 to disable or 1 to enable the TCP/IP protocol.
TCPENABLED="1"
; Specify 0 to disable or 1 to enable the Named Pipes protocol.
NPENABLED="1"
; Startup type for Browser Service.
BROWSERSVCSTARTUPTYPE="Automatic"
My Install script
#Importeer ServerManager
Import-Module ServerManager
#Install IIS
Add-WindowsFeature Web-Server -IncludeAllSubFeature
#Installeer .Net-Framework
Add-WindowsFeature net-Framework
#Importeer WebAdministration & Web-Mgmt-Service
Import-Module WebAdministration
#Installeer Web-Mgmt-Service
Add-WindowsFeature Web-Mgmt-Service
#Installeer .NET 4
./dotNetFx40_Full_x86_x64_SC.exe
write-host ".NET installed"
# Install Web Deploy
Write-Host "Installing Web Deploy"
.\WebDeploy_amd64_en-US.msi ADDLOCAL=ALL /qn
Write-Host "INSTALLED Web Deploy"
# Install Microsoft® Core XML Services, needed for SMO
Write-Host "Installing Microsoft Core XML SERVICES"
.\msxml6_x64.msi ADDLOCAL=ALL /qn
Write-Host "Installed Microsoft Core XML SERVICES"
#Install CLR Types
Write-Host "Installing CLR TYPES"
.\SQLSysClrTypes.msi ADDLOCAL=ALL /qn
Write-Host "Installed CLR TYPES"
# Install MS SQL Server Management Objects.
Write-Host "Installing MS SQL Server Management Objects"
./SharedManagementObjects.msi ADDLOCAL=ALL /qn
Write-Host "Installed MS SQL Server Management Objects"
#Install SQL SERVER
Write-Host "Installing SQL SERVER"
.\setup.exe /ConfigurationFile=ConfigurationFile.ini
Write-Host "INSTALLED SQL SERVER"
Clear-Host
$teamnaam = "ErosRammazani"
$teampass = "Opleelan8"
$sitePort="8007"
$sqlServerInstanceName="MSSQLSERVER"
$sqlServerName=$sqlServerInstanceName
$databaseAdminUser="sa"
$databaseAdminPassword="Opleelan8"
$Sitedir="C:\inetpub"
$Settingsdir="C:\inetprofiles"
$Scriptdir="C:\Program Files\IIS\Microsoft Web Deploy V3\Scripts"
$AppCmd="C:\Windows\System32\inetsrv\appcmd.exe"
# .NET toegang geven tot databank
$aspnet="C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\aspnet_regsql.exe"
# Path tests
Set-Location -Path "$Scriptdir"
if (!(Test-Path -path $Sitedir)) {New-Item $Sitedir -Type Directory}
if (!(Test-Path -path $Settingsdir)) {New-Item $Settingsdir -Type Directory}
if (!(Test-Path ".\SetupSiteForPublish.ps1"))
{ Write-Host -NoNewline "Installeer Wdeploy.exe"; Exit 1 }
##################### User per team aanmaken
net user $teamnaam $teampass /add /passwordchg:no /expires:never /active:yes /fullname:$teamnaam /comment:$teamnaam
# Set the FTP user account’s password not to expire
$WMI = gwmi win32_useraccount | where {$_.name -eq $teamnaam}
$WMI.PasswordExpires = $False
$WMI.put()
###################### Site publiceren in IIS . Elk team een eigen App Pool
Write-Host -NoNewline "publiceren site $teamnaam"
$siteName=$teamnaam
$sitePhysicalPath=$Sitedir+"\"+$siteName
$siteAppPoolName=$teamnaam+"AppPool"
$deploymentUserName=$teamnaam
$deploymentUserPassword=$teampass
$managedRunTimeVersion="v4.0"
.\SetupSiteForPublish.ps1 -siteName $siteName -sitePhysicalPath $sitePhysicalPath -siteAppPoolName $siteAppPoolName -sitePort $sitePort -deploymentUserName $deploymentUserName -deploymentUserPassword $deploymentUserPassword -publishSettingSavePath $Settingsdir -publishSettingFileName $siteName".PublishSettings" -managedRunTimeVersion $managedRunTimeVersion
################### SQL db aanmaken
Write-Host -NoNewline "SQL db aanmaken voor $teamnaam"
$databaseName="db$teamnaam"
$databaseUserName="dbuser$teamnaam"
$databaseUserPassword=$teampass
Set-Location -Path "$Scriptdir"
.\CreateSqlDatabase.ps1 -databaseName $databaseName -databaseUserName $databaseUserName -databaseUserPassword $databaseUserPassword -databaseAdminUser $databaseAdminUser -databaseAdminPassword $databaseAdminPassword -sqlServerInstanceName $sqlServerInstanceName -publishSettingSavePath $Settingsdir -publishSettingFileName $databaseName".PublishSettings"
#################### Default pagina klaarzetten op de site
echo "<html><body><h2>Default pagina $teamnaam</h2><p><%Response.Write(now())
%></p></body></html>" | Out-File $sitePhysicalPath\default.aspx
# Virtuele dir op default website
& $appcmd ADD vdir /app.name:"Default Web Site/" /path:/$teamnaam /physicalPath:C:\$Sitedir\$teamnaam
# .NET toegang geven tot databank
# -A toegang tot alle features -E login/pass van huidige user gebruiken
Write-Host -NoNewline ".NET toegang tot db"
& $aspnet -S $sqlServerName -d $databaseName -A all -E
# FTP toegang tot site , FTP site was manueel aangemaakt in IIS
if (!(Test-Path -path $sitePhysicalPath)) {New-Item $sitePhysicalPath -Type Directory}
& $AppCmd set config "FTP" -section:system.ftpServer/security/authorization /+"[accessType='Allow',users='$teamnaam',permissions='Read, Write']" /commit:apphost
######### open extra ports in firewall
Write-Host -NoNewline "Setting Windows Firewall rules for $teamnaam "
netsh advfirewall firewall add rule name="Projecten-$teamnaam-IN" dir=in action=allow protocol=TCP localport=$sitePort
netsh advfirewall firewall add rule name="Projecten-$teamnaam-OUT" dir=out action=allow protocol=TCP remoteport=$sitePort

migrate sdf file to sql server

I created code first approach application mvc and it created sdf file db. Now I want to migrate that sdf file to sql server.
When I double click on sdf, It says message like This is not a valid SQL Server Compact Database file or this file version is not supported by current SQL Server Compact Engine.
I want to migrate,sync data to sql server of any better approach for future, how can I migrate db?
A possible reason for the error message is that you do not have the correct version of SQL Server Compact installed on your development machine.
The current version is 4.0, but your application might still be using 3.5. Find out which version it is and check the folder C:\Program Files\Microsoft SQL Server Compact Edition to see if there's a directory with that version name. If there isn't, download and install it (3.5, 4.0).
If you are using SqlCE 4.0 and Visual Studio 2010 Pro or higher, you can migrate the sdf's structure and data using ErikEJ's SQL Server Compact Toolbox 3.3.0.4 which is available through Visual Studio's Extension Manager.
After you have installed the Toolbox, the migration steps are as follows:
Using the Toolbox, connect to your sdf file within Visual Studio.
From the context menu, choose Script Database > Script Database Schema and Data (do not choose Script Database Schema and Data with BLOBS). This will save one or more '.sqlce' script files, depending on how large your sdf is.
In your SQL Server instance, create an empty target database.
Locate the SQLCMD.exe of your Sql Server installation. For SQL Server 2008 it typically is at C:\Program Files\Microsoft SQL Server\100\Tools\Binn. Open a regular cmd.exe with administrator rights and navigate to the directory containing SQLCMD.exe.
From there, execute:
sqlcmd -S [sql server instance name] /d [target database name] -i
[full path][filename].sqlce
If you have multiple sqlce files, you can reference them in the same command like this:
sqlcmd -S [sql server instance name] /d [target database name] -i
[full path][filename_0].sqlce -i [full path][filename_1].sqlce -i
[full path][filename_2].sqlce
The server option -S needs to be a capital. Good luck.

Resources