-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathPowershell API.ps1
74 lines (43 loc) · 1.81 KB
/
Powershell API.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
$url = "http://dineshapi.azurewebsites.net/api/Student"
$student = @{
name='Dinesh patil'
company='GeneralMills'
isPresent = "True"
}
$body = (ConvertTo-Json $student)
Invoke-RestMethod -Uri $url -Method Post -Body $body -ContentType 'application/json'
$student = @{
name='basant nayak'
company='Netmagic'
isPresent = "True"
}
$body = (ConvertTo-Json $student)
Invoke-RestMethod -Uri $url -Method Post -Body $body -ContentType 'application/json'
$Allstudents = Invoke-RestMethod -Uri $url -Method get
Invoke-RestMethod -Uri $url -Method get -ContentType 'application/json'
$id="dcb2d79be1fd4accabf3d1f93f9a5e80"
$puturl = "http://dineshapi.azurewebsites.net/api/student/$id"
$updatestudent = @{
name='Dinesh Patil'
company='generalmills'
isPresent = "False"
isCompleted = "True"
}
$body = (ConvertTo-Json $updatestudent)
Invoke-RestMethod -Uri $puturl -Method Put -Body $body -ContentType 'application/json'
$id="16b7a5fdb0ed44feba2fd661f4f873a0"
$deleteurl = "http://dineshapi.azurewebsites.net/api/student/$id"
#$cred = Get-Credential
Invoke-RestMethod -Uri $deleteurl -Method Delete -Credential $cred
$site = Invoke-WebRequest http://www.bing.com
$site | gm
$site.StatusCode
$site.StatusDescription
#Download files
$param = @{URI="https://download.sysinternals.com/files/SysinternalsSuite.zip";Outfile = "C:\demo\sys.zip" }
Invoke-RestMethod @param
to download large file
$url = "https://download.sysinternals.com/files/SysinternalsSuite.zip"
$target = "C:\Demo\sys1.zip"
Import-Module BitsTransfer
Start-BitsTransfer -Source $url -Destination $target -DisplayName Mysysdownload -Asynchronous